|
| 1 | +:mod:`_io` -- input/output streams |
| 2 | +================================== |
| 3 | + |
| 4 | +.. module:: _io |
| 5 | + :synopsis: input/output streams |
| 6 | + |
| 7 | +This module contains additional types of stream (file-like) objects |
| 8 | +and helper functions. |
| 9 | + |
| 10 | +Functions |
| 11 | +--------- |
| 12 | + |
| 13 | +.. function:: open(name, mode='r', **kwargs) |
| 14 | + |
| 15 | + Open a file. Builtin ``open()`` function is alised to this function. |
| 16 | + All ports (which provide access to file system) are required to support |
| 17 | + `mode` parameter, but support for other arguments vary by port. |
| 18 | + |
| 19 | +Classes |
| 20 | +------- |
| 21 | + |
| 22 | +.. class:: FileIO(...) |
| 23 | + |
| 24 | + This is type of a file open in binary mode, e.g. using ``open(name, "rb")``. |
| 25 | + You should not instantiate this class directly. |
| 26 | + |
| 27 | +.. class:: TextIOWrapper(...) |
| 28 | + |
| 29 | + This is type of a file open in text mode, e.g. using ``open(name, "rt")``. |
| 30 | + You should not instantiate this class directly. |
| 31 | + |
| 32 | +.. class:: StringIO([string]) |
| 33 | +.. class:: BytesIO([string]) |
| 34 | + |
| 35 | + In-memory file-like objects for input/output. `StringIO` is used for |
| 36 | + text-mode I/O (similar to a normal file opened with "t" modifier). |
| 37 | + `BytesIO` is used for binary-mode I/O (similar to a normal file |
| 38 | + opened with "b" modifier). Initial contents of file-like objects |
| 39 | + can be specified with `string` parameter (should be normal string |
| 40 | + for `StringIO` or bytes object for `BytesIO`). All the usual file |
| 41 | + methods like ``read()``, ``write()``, ``close()`` are available on |
| 42 | + these objects, and additionally, following method: |
| 43 | + |
| 44 | + .. method:: getvalue() |
| 45 | + |
| 46 | + Get the current contents of the underlying buffer which holds data. |
0 commit comments