summaryrefslogtreecommitdiffstats
path: root/Doc/library/io.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-03 22:56:19 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-03 22:56:19 (GMT)
commit3c25dfbf13279c90cf35e5b4424f1c94483306d3 (patch)
treebacac08cbfed9dcd878170aed00afedf864a01df /Doc/library/io.rst
parentba9b404b6570796aa9a7f6ad47bd0ca033aa6cc0 (diff)
parent0c1c0d42dcc8fc223eb3aaa51d09d252b1738820 (diff)
downloadcpython-3c25dfbf13279c90cf35e5b4424f1c94483306d3.zip
cpython-3c25dfbf13279c90cf35e5b4424f1c94483306d3.tar.gz
cpython-3c25dfbf13279c90cf35e5b4424f1c94483306d3.tar.bz2
Make TextIOWrapper's documentation clearer by copying the newline argument's description from open().
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r--Doc/library/io.rst24
1 files changed, 16 insertions, 8 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 23d6c6d..0aadc9d 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -767,14 +767,22 @@ Text I/O
sequences) can be used. Any other error handling name that has been
registered with :func:`codecs.register_error` is also valid.
- *newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It
- controls the handling of line endings. If it is ``None``, universal newlines
- is enabled. With this enabled, on input, the lines endings ``'\n'``,
- ``'\r'``, or ``'\r\n'`` are translated to ``'\n'`` before being returned to
- the caller. Conversely, on output, ``'\n'`` is translated to the system
- default line separator, :data:`os.linesep`. If *newline* is any other of its
- legal values, that newline becomes the newline when the file is read and it
- is returned untranslated. On output, ``'\n'`` is converted to the *newline*.
+ *newline* controls how line endings are handled. It can be ``None``,
+ ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
+
+ * On input, if *newline* is ``None``, universal newlines mode is enabled.
+ Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these
+ are translated into ``'\n'`` before being returned to the caller. If it is
+ ``''``, universal newline mode is enabled, but line endings are returned to
+ the caller untranslated. If it has any of the other legal values, input
+ lines are only terminated by the given string, and the line ending is
+ returned to the caller untranslated.
+
+ * On output, if *newline* is ``None``, any ``'\n'`` characters written are
+ translated to the system default line separator, :data:`os.linesep`. If
+ *newline* is ``''``, no translation takes place. If *newline* is any of
+ the other legal values, any ``'\n'`` characters written are translated to
+ the given string.
If *line_buffering* is ``True``, :meth:`flush` is implied when a call to
write contains a newline character.