[Python-Dev] Pre-PEP: Unifying try-except and try-finally

Timothy Fitz firemoth at gmail.com
Wed May 11 01:28:21 CEST 2005


> No, as except clauses can only occur before the finally clause, and execution
> should not go backwards.

This restriction feels a bit arbitrary. I can guarantee someone is
going to flatten this:

try:
    try:
        A
    finally:
        B
except IOError:
   C

A more flexible approach would be to allow finally at the beginning or
ending of the try statement. A more flexible approach would be to
allow both, or even finally clauses mixed in.

To me, that's the ugly portion of this proposal, it's quite arbitrary.
And the alternatives I posted have their own brands of ugly.
Concisely, this is an arbitrary shortcut for an idiom that already
exists. It seems to me that this shortcut would be redundant if PEP
340 or something with similar functionality was accepted.


More information about the Python-Dev mailing list