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 kristjan.jonsson
Recipients kristjan.jonsson, ncoghlan, r.david.murray
Date 2013-08-07.14:59:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375887598.35.0.27585960555.issue18677@psf.upfronthosting.co.za>
In-reply-to
Content
IMHO, exitstack is not a very nice construct.  It's implementation is far longer than contextlib.nested.

And the chief problem still remains, which has not been addressed until this patch (as far as I know):
In Python, it is impossible to combine existing context managers into a nested one.  ExitStack may address a use case of nested context managers, but it doesn't address the basic problem.

ContextManagerExit comes with its own nice little features, too.  Now you can write:

@contextlib.contextmanager:
def if_ctxt(condition):
    if condition:
        yield

#hey look! an if statement as a with statement!
with if_ctxt(condition):
    do_work

This can easily be extended, where a context manager can both manage context, _and_ provide optional execution of its block.
History
Date User Action Args
2013-08-07 14:59:58kristjan.jonssonsetrecipients: + kristjan.jonsson, ncoghlan, r.david.murray
2013-08-07 14:59:58kristjan.jonssonsetmessageid: <1375887598.35.0.27585960555.issue18677@psf.upfronthosting.co.za>
2013-08-07 14:59:58kristjan.jonssonlinkissue18677 messages
2013-08-07 14:59:57kristjan.jonssoncreate