diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2022-08-21 14:42:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-21 14:42:15 (GMT) |
commit | 511dea0a3ea9beb2fd72c7c689e2b1cb1636a6fa (patch) | |
tree | 44a253107865d560b782d766df04ae33b6899812 | |
parent | 0e28a3a50ff9c612a2a745907ebcb30911fd51e8 (diff) | |
download | cpython-511dea0a3ea9beb2fd72c7c689e2b1cb1636a6fa.zip cpython-511dea0a3ea9beb2fd72c7c689e2b1cb1636a6fa.tar.gz cpython-511dea0a3ea9beb2fd72c7c689e2b1cb1636a6fa.tar.bz2 |
GH-95880: Clarify StringIO append/overwrite behavior. (GH-96104)
-rw-r--r-- | Doc/library/io.rst | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 753e6c1..97a7064 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -1052,8 +1052,12 @@ Text I/O The initial value of the buffer can be set by providing *initial_value*. If newline translation is enabled, newlines will be encoded as if by - :meth:`~TextIOBase.write`. The stream is positioned at the start of - the buffer. + :meth:`~TextIOBase.write`. The stream is positioned at the start of the + buffer which emulates opening an existing file in a `w+` mode, making it + ready for an immediate write from the beginning or for a write that + would overwrite the initial value. To emulate opening a file in an `a+` + mode ready for appending, use `f.seek(0, io.SEEK_END)` to reposition the + stream at the end of the buffer. The *newline* argument works like that of :class:`TextIOWrapper`, except that when writing output to the stream, if *newline* is ``None``, |