Skip to content

Commit

Permalink
Note regarding + mode truncation applies to both text and binary mode (
Browse files Browse the repository at this point in the history
#11314)

* Improve doc on open's mode +

* Improve wording

* Address comment from Rémi
  • Loading branch information
andresdelfino authored and DinoV committed Sep 10, 2019
1 parent b7f8e52 commit c1d8c1c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Doc/library/functions.rst
Expand Up @@ -1070,12 +1070,12 @@ are always available. They are listed here in alphabetical order.
``'a'`` open for writing, appending to the end of the file if it exists
``'b'`` binary mode
``'t'`` text mode (default)
``'+'`` open a disk file for updating (reading and writing)
``'+'`` open for updating (reading and writing)
========= ===============================================================

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

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

0 comments on commit c1d8c1c

Please sign in to comment.