Commit ce77ee91 authored by Berker Peksag's avatar Berker Peksag

Issue #22154: Add an example to show context management protocol support of ZipFile.open().

Patch by Mike Short.
parent a60c2fe4
......@@ -210,6 +210,13 @@ ZipFile Objects
password used for encrypted files. Calling :meth:`.open` on a closed
ZipFile will raise a :exc:`RuntimeError`.
:func:`~ZipFile.open` is also a context manager and therefore supports the
:keyword:`with` statement::
with ZipFile('spam.zip') as myzip:
with myzip.open('eggs.txt') as myfile:
print(myfile.read())
.. note::
The file-like object is read-only and provides the following methods:
......
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