Skip to content

Commit 8072230

Browse files
miss-islingtonandresdelfino
authored andcommitted
Note regarding + mode truncation applies to both text and binary mode (GH-11314) (GH-15869)
* Improve doc on open's mode + * Improve wording * Address comment from Rémi (cherry picked from commit c1d8c1c) Co-authored-by: Andre Delfino <[email protected]>
1 parent 97c2f68 commit 8072230

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/functions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,12 @@ are always available. They are listed here in alphabetical order.
10681068
``'a'`` open for writing, appending to the end of the file if it exists
10691069
``'b'`` binary mode
10701070
``'t'`` text mode (default)
1071-
``'+'`` open a disk file for updating (reading and writing)
1071+
``'+'`` open for updating (reading and writing)
10721072
========= ===============================================================
10731073

10741074
The default mode is ``'r'`` (open for reading text, synonym of ``'rt'``).
1075-
For binary read-write access, the mode ``'w+b'`` opens and truncates the file
1076-
to 0 bytes. ``'r+b'`` opens the file without truncation.
1075+
Modes ``'w+'`` and ``'w+b'`` opens and truncates the file. Modes ``'r+'``
1076+
and ``'r+b'`` opens the file with no truncation.
10771077

10781078
As mentioned in the :ref:`io-overview`, Python distinguishes between binary
10791079
and text I/O. Files opened in binary mode (including ``'b'`` in the *mode*

0 commit comments

Comments
 (0)