Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b85a584

Browse files
committed
A few io doc fixes
1 parent 33fe809 commit b85a584

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

Doc/library/io.rst

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ a buffered text interface to a buffered raw stream (:class:`BufferedIOBase`).
3333
Finally, :class:`StringIO` is a in-memory stream for text.
3434

3535
Argument names are not part of the specification, and only the arguments of
36-
:func:`open()` are intended to be used as keyword arguments.
36+
:func:`open` are intended to be used as keyword arguments.
3737

3838

3939
Module Interface
@@ -42,7 +42,7 @@ Module Interface
4242
.. data:: DEFAULT_BUFFER_SIZE
4343

4444
An int containing the default buffer size used by the module's buffered I/O
45-
classes. :func:`open()` uses the file's blksize (as obtained by
45+
classes. :func:`open` uses the file's blksize (as obtained by
4646
:func:`os.stat`) if possible.
4747

4848
.. function:: open(file[, mode[, buffering[, encoding[, errors[, newline[, closefd=True]]]]]])
@@ -100,13 +100,14 @@ Module Interface
100100
dependent, but any encoding supported by Python can be passed. See the
101101
:mod:`codecs` module for the list of supported encodings.
102102

103-
*errors* is an optional string that specifies how encoding errors are to be
104-
handled---this argument should not be used in binary mode. Pass ``'strict'``
105-
to raise a :exc:`ValueError` exception if there is an encoding error (the
106-
default of ``None`` has the same effect), or pass ``'ignore'`` to ignore
107-
errors. (Note that ignoring encoding errors can lead to data loss.) See the
108-
documentation for :func:`codecs.register` for a list of the permitted
109-
encoding error strings.
103+
*errors* is an optional string that specifies how encoding and decoding
104+
errors are to be handled---this argument should not be used in binary mode.
105+
Pass ``'strict'`` to raise a :exc:`ValueError` exception if there is an
106+
encoding error (the default of ``None`` has the same effect), or pass
107+
``'ignore'`` to ignore errors. (Note that ignoring encoding errors can lead
108+
to data loss.) ``'replace'`` causes a replacement marker (such as ``'?'``)
109+
to be inserted where there is malformed data. For all possible values, see
110+
:func:`codecs.register`.
110111

111112
*newline* controls how universal newlines works (it only applies to text
112113
mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It
@@ -130,15 +131,14 @@ Module Interface
130131
when the file is closed. This does not work when a file name is given and
131132
must be ``True`` in that case.
132133

133-
:func:`open()` returns a file object whose type depends on the mode, and
134+
:func:`open` returns a file object whose type depends on the mode, and
134135
through which the standard file operations such as reading and writing are
135-
performed. When :func:`open()` is used to open a file in a text mode
136-
(``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a
137-
:class:`TextIOWrapper`. When used to open a file in a binary mode, the
138-
returned class varies: in read binary mode, it returns a
139-
:class:`BufferedReader`; in write binary and append binary modes, it returns
140-
a :class:`BufferedWriter`, and in read/write mode, it returns a
141-
:class:`BufferedRandom`.
136+
performed. When :func:`open` is used to open a file in a text mode (``'w'``,
137+
``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a :class:`TextIOWrapper`.
138+
When used to open a file in a binary mode, the returned class varies: in read
139+
binary mode, it returns a :class:`BufferedReader`; in write binary and append
140+
binary modes, it returns a :class:`BufferedWriter`, and in read/write mode,
141+
it returns a :class:`BufferedRandom`.
142142

143143
It is also possible to use a string or bytearray as a file for both reading
144144
and writing. For strings :class:`StringIO` can be used like a file opened in
@@ -220,8 +220,8 @@ I/O Base Classes
220220

221221
.. method:: flush()
222222

223-
Flush the write buffers of the stream if applicable. This is not
224-
implemented for read-only and non-blocking streams.
223+
Flush the write buffers of the stream if applicable. This does nothing
224+
for read-only and non-blocking streams.
225225

226226
.. method:: isatty()
227227

@@ -238,7 +238,7 @@ I/O Base Classes
238238
*limit* bytes will be read.
239239

240240
The line terminator is always ``b'\n'`` for binary files; for text files,
241-
the *newlines* argument to :func:`.open()` can be used to select the line
241+
the *newlines* argument to :func:`open` can be used to select the line
242242
terminator(s) recognized.
243243

244244
.. method:: readlines([hint])
@@ -576,8 +576,13 @@ Text I/O
576576
*encoding* gives the name of the encoding that the stream will be decoded or
577577
encoded with. It defaults to :func:`locale.getpreferredencoding`.
578578

579-
*errors* determines the strictness of encoding and decoding (see the errors
580-
argument of :func:`codecs.register`) and defaults to ``'strict'``.
579+
*errors* is an optional string that specifies how encoding and decoding
580+
errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError`
581+
exception if there is an encoding error (the default of ``None`` has the same
582+
effect), or pass ``'ignore'`` to ignore errors. (Note that ignoring encoding
583+
errors can lead to data loss.) ``'replace'`` causes a replacement marker
584+
(such as ``'?'``) to be inserted where there is malformed data. For all
585+
possible values see :func:`codecs.register`.
581586

582587
*newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It
583588
controls the handling of line endings. If it is ``None``, universal newlines

0 commit comments

Comments
 (0)