gzip and bz2 are context managers

This commit is contained in:
Benjamin Peterson 2009-03-09 20:38:56 +00:00
parent 38f1bf6745
commit 6d83429a1d
2 changed files with 10 additions and 0 deletions

View File

@ -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()

View File

@ -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]])