[issue21067] Support Multiple finally clauses.

2014-03-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > If you think this should go forward please discuss it > on the python-ideas list. For it to go forward a PEP > will likely need to be written. I concur with this assessment. Marking this as closed. -- nosy: +rhettinger resolution: -> rejected s

[issue21067] Support Multiple finally clauses.

2014-03-25 Thread Josh Rosenberg
Josh Rosenberg added the comment: And for this particular case, even if the resource allocators don't support the context manager protocol, contextlib.closing can do the job: from contextlib import closing with closing(allocateresource1()) as resource1, closing(allocateresource2()) as

[issue21067] Support Multiple finally clauses.

2014-03-25 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue21067] Support Multiple finally clauses.

2014-03-25 Thread Georg Brandl
Georg Brandl added the comment: For resource management, it would be more idiomatic to use context managers, either with multiple CMs in one with-statement or, dynamically, with contextlib.ExitStack. For test suites using unittest, there is also the addCleanup functionality of the TestCase.

[issue21067] Support Multiple finally clauses.

2014-03-25 Thread Kevin Cox
New submission from Kevin Cox: I think it would be useful to support multiple finally clauses. The idea would be that each clause would be run, even if prior clauses throw exceptions. The idea came when hunting a bug in the Mozilla test suite. The code looked like as follows. try: r