[New-bugs-announce] [issue5491] Clarify contextlib.nested semantics

Nick Coghlan report at bugs.python.org
Sun Mar 15 05:51:10 CET 2009


New submission from Nick Coghlan <ncoghlan at gmail.com>:

Current doc example:

with nested(A, B, C) as (X, Y, Z):
    do_something()

with A as X:
    with B as Y:
        with C as Z:
            do_something()

Recommended docs change:

with nested(A(), B(), C()) as (X, Y, Z):
    do_something()

m1, m2, m3 = A(), B(), C()
with m1 as X:
    with m2 as Y:
        with m3 as Z:
            do_something()

This makes it clearer that when using nested, the context managers are
all created outside the scope of the with statement.

----------
assignee: georg.brandl
components: Documentation
messages: 83619
nosy: georg.brandl, ncoghlan
severity: normal
status: open
title: Clarify contextlib.nested semantics

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5491>
_______________________________________


More information about the New-bugs-announce mailing list