Skip to content

Commit c1d8c1c

Browse files
andresdelfinoDinoV
authored andcommitted
Note regarding + mode truncation applies to both text and binary mode (#11314)
* Improve doc on open's mode + * Improve wording * Address comment from Rémi
1 parent b7f8e52 commit c1d8c1c

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
@@ -1070,12 +1070,12 @@ are always available. They are listed here in alphabetical order.
10701070
``'a'`` open for writing, appending to the end of the file if it exists
10711071
``'b'`` binary mode
10721072
``'t'`` text mode (default)
1073-
``'+'`` open a disk file for updating (reading and writing)
1073+
``'+'`` open for updating (reading and writing)
10741074
========= ===============================================================
10751075

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

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

0 commit comments

Comments
 (0)