#5491: clarify nested() semantics.
This commit is contained in:
parent
ed4cefbedd
commit
5a95b21fee
|
@ -63,14 +63,15 @@ Functions provided:
|
||||||
|
|
||||||
from contextlib import nested
|
from contextlib import nested
|
||||||
|
|
||||||
with nested(A, B, C) as (X, Y, Z):
|
with nested(A(), B(), C()) as (X, Y, Z):
|
||||||
do_something()
|
do_something()
|
||||||
|
|
||||||
is equivalent to this::
|
is equivalent to this::
|
||||||
|
|
||||||
with A as X:
|
m1, m2, m3 = A(), B(), C()
|
||||||
with B as Y:
|
with m1 as X:
|
||||||
with C as Z:
|
with m2 as Y:
|
||||||
|
with m3 as Z:
|
||||||
do_something()
|
do_something()
|
||||||
|
|
||||||
Note that if the :meth:`__exit__` method of one of the nested context managers
|
Note that if the :meth:`__exit__` method of one of the nested context managers
|
||||||
|
|
Loading…
Reference in New Issue