summaryrefslogtreecommitdiffstats
path: root/Doc/library/contextlib.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-03-15 21:44:43 (GMT)
committerGeorg Brandl <georg@python.org>2009-03-15 21:44:43 (GMT)
commit5a95b21fee671bde9ab843a6a503cce5dafeb002 (patch)
tree71a68858d1ddff8d16f38f8b8c74561000098ccf /Doc/library/contextlib.rst
parented4cefbedd1817247b94e5880f850bc1c3f6628d (diff)
downloadcpython-5a95b21fee671bde9ab843a6a503cce5dafeb002.zip
cpython-5a95b21fee671bde9ab843a6a503cce5dafeb002.tar.gz
cpython-5a95b21fee671bde9ab843a6a503cce5dafeb002.tar.bz2
#5491: clarify nested() semantics.
Diffstat (limited to 'Doc/library/contextlib.rst')
-rw-r--r--Doc/library/contextlib.rst9
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index 8c10c95..935afee 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -63,14 +63,15 @@ Functions provided:
from contextlib import nested
- with nested(A, B, C) as (X, Y, Z):
+ with nested(A(), B(), C()) as (X, Y, Z):
do_something()
is equivalent to this::
- with A as X:
- with B as Y:
- with C as Z:
+ m1, m2, m3 = A(), B(), C()
+ with m1 as X:
+ with m2 as Y:
+ with m3 as Z:
do_something()
Note that if the :meth:`__exit__` method of one of the nested context managers