Kristján Valur Jónsson added the comment:
Using my latest patch, the ExitStack inline example can be rewritten:
with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]
# All opened files will automatically be closed at the end of
# the with statement, even if attempts to open files later
# in the list raise an exception
becomes:
with nested(opened(fname) for fname in filenames) as files:
do_stuff_with_files(files)
----------
_______________________________________
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