Skip to content

Commit 50cb936

Browse files
committed
Clarify acceptable values for BZ2File.__init__'s mode argument.
1 parent aebcdba commit 50cb936

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Doc/library/bz2.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ All of the classes in this module may safely be accessed from multiple threads.
3535
be used to read or write the compressed data.
3636

3737
The *mode* argument can be either ``'r'`` for reading (default), ``'w'`` for
38-
overwriting, or ``'a'`` for appending. If *filename* is a file object (rather
39-
than an actual file name), a mode of ``'w'`` does not truncate the file, and
40-
is instead equivalent to ``'a'``.
38+
overwriting, or ``'a'`` for appending. These can equivalently be given as
39+
``'rb'``, ``'wb'``, and ``'ab'`` respectively.
40+
41+
If *filename* is a file object (rather than an actual file name), a mode of
42+
``'w'`` does not truncate the file, and is instead equivalent to ``'a'``.
4143

4244
The *buffering* argument is ignored. Its use is deprecated.
4345

Lib/bz2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def __init__(self, filename, mode="r", buffering=None, compresslevel=9):
4646
be opened. Otherwise, it should be a file object, which will be used to
4747
read or write the compressed data.
4848
49-
mode can be 'r' for reading (default), 'w' for (over)writing, or
50-
'a' for appending.
49+
mode can be 'r' for reading (default), 'w' for (over)writing, or 'a' for
50+
appending. These can equivalently be given as 'rb', 'wb', and 'ab'.
5151
5252
buffering is ignored. Its use is deprecated.
5353

0 commit comments

Comments
 (0)