mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
gzip and bz2 are context managers
This commit is contained in:
parent
38f1bf6745
commit
6d83429a1d
2 changed files with 10 additions and 0 deletions
|
@ -60,6 +60,11 @@ Handling of compressed files is offered by the :class:`BZ2File` class.
|
|||
reading. Instances support iteration in the same way as normal :class:`file`
|
||||
instances.
|
||||
|
||||
:class:`BZ2File` supports the :keyword:`with` statement.
|
||||
|
||||
.. versionchanged:: 2.7
|
||||
Support for the :keyword:`with` statement was added.
|
||||
|
||||
|
||||
.. method:: close()
|
||||
|
||||
|
|
|
@ -67,6 +67,11 @@ The module defines the following items:
|
|||
writing as *fileobj*, and retrieve the resulting memory buffer using the
|
||||
:class:`StringIO` object's :meth:`getvalue` method.
|
||||
|
||||
:class:`GzipFile` supports the :keyword:`with` statement.
|
||||
|
||||
.. versionchanged:: 2.7
|
||||
Support for the :keyword:`with` statement was added.
|
||||
|
||||
|
||||
.. function:: open(filename[, mode[, compresslevel]])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue