Nick Coghlan added the comment: I pitched the idea of making it possible to skip the with statement body quite some time ago, and Guido convinced me it was a bad idea for much the same reason he chose PEP 343 over his original PEP 340 design: allowing suppression of exceptions from __enter__ hides local control flow by blurring the boundaries between with and if statements.
Regarding nested, we killed that because it was a bug magnet for context managers that acquire the resource in __init__ (like file objects), not because it didn't work. It's trivial to recreate that API on top of ExitStack if you like it, though. The only thing that doesn't work (relative to actual nested with statements) is suppressing exceptions raised inside __enter__ methods. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18677> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com