projects
/
python
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a60c2fe
)
Issue #22154: Add an example to show context management protocol support of ZipFile...
author
Berker Peksag
<berker.peksag@gmail.com>
Fri, 13 Mar 2015 00:29:54 +0000
(
02:29
+0200)
committer
Berker Peksag
<berker.peksag@gmail.com>
Fri, 13 Mar 2015 00:29:54 +0000
(
02:29
+0200)
Patch by Mike Short.
Doc/library/zipfile.rst
patch
|
blob
|
history
diff --git
a/Doc/library/zipfile.rst
b/Doc/library/zipfile.rst
index 1d23a7c4d2e1a51bf2775420cbf9899ecdbe1be7..b416bf7e1844c9ce97f1bcf78cac40b1f7ed9ccd 100644
(file)
--- a/
Doc/library/zipfile.rst
+++ b/
Doc/library/zipfile.rst
@@
-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: