This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Julian, eric.araujo, eric.snow, giampaolo.rodola, meador.inge, ncoghlan, nikratio, pitrou, rhettinger, smarnach
Date 2012-05-01.12:22:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1335874962.83.0.824479454842.issue13585@psf.upfronthosting.co.za>
In-reply-to
Content
Latest draft of API is here: http://contextlib2_dev.readthedocs.org/en/latest/index.html#contextlib2.ExitStack

An updated version of the "I forgot I could use multiple context managers in a with statement" example:

    with ExitStack() as stack:
        src = open(source)
        stack.callback(src.close)
        dest = open(destination, 'w')
        stack.callback(dest.close)
        copy(src, dest)

The example of opening a collection of files remains unchanged (aside from s/ContextStack/ExitStack/).

Also see: http://contextlib2_dev.readthedocs.org/en/latest/index.html#replacing-any-use-of-try-finally-and-flag-variables
History
Date User Action Args
2012-05-01 12:22:42ncoghlansetrecipients: + ncoghlan, rhettinger, pitrou, giampaolo.rodola, eric.araujo, nikratio, meador.inge, Julian, eric.snow, smarnach
2012-05-01 12:22:42ncoghlansetmessageid: <1335874962.83.0.824479454842.issue13585@psf.upfronthosting.co.za>
2012-05-01 12:22:42ncoghlanlinkissue13585 messages
2012-05-01 12:22:42ncoghlancreate