Kristján Valur Jónsson added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18677>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com