Commit 6d83429a authored by Benjamin Peterson's avatar Benjamin Peterson

gzip and bz2 are context managers

parent 38f1bf67
...@@ -60,6 +60,11 @@ Handling of compressed files is offered by the :class:`BZ2File` class. ...@@ -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` reading. Instances support iteration in the same way as normal :class:`file`
instances. instances.
:class:`BZ2File` supports the :keyword:`with` statement.
.. versionchanged:: 2.7
Support for the :keyword:`with` statement was added.
.. method:: close() .. method:: close()
......
...@@ -67,6 +67,11 @@ The module defines the following items: ...@@ -67,6 +67,11 @@ The module defines the following items:
writing as *fileobj*, and retrieve the resulting memory buffer using the writing as *fileobj*, and retrieve the resulting memory buffer using the
:class:`StringIO` object's :meth:`getvalue` method. :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]]) .. function:: open(filename[, mode[, compresslevel]])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment