Skip to content

Commit 8ebdbcf

Browse files
committed
docs: Add _io module reference.
1 parent 348caaf commit 8ebdbcf

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

docs/library/_io.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.

docs/library/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ library.
3030
cmath.rst
3131
_collections.rst
3232
gc.rst
33+
_io.rst
3334
math.rst
3435
select.rst
3536
sys.rst
@@ -52,6 +53,7 @@ library.
5253
cmath.rst
5354
_collections.rst
5455
gc.rst
56+
_io.rst
5557
math.rst
5658
select.rst
5759
sys.rst
@@ -89,6 +91,7 @@ library.
8991

9092
_collections.rst
9193
gc.rst
94+
_io.rst
9295
math.rst
9396
sys.rst
9497
ubinascii.rst

0 commit comments

Comments
 (0)