[Python-Dev] suggestion for try/except program flow

Mark Donald foobarmus at gmail.com
Fri Mar 27 09:57:38 CET 2009


I frequently have this situation:

try:
    try:
        raise Thing
    except Thing, e:
        # handle Thing exceptions
        raise
except:
    # handle all exceptions, including Thing

It would be much more readable if there were a way to recatch a named
exception with the generic (catch-all) except clause of its own try,
something like this:

try:
    raise Thing
except Thing, e:
    # handle Thing exceptions
    recatch
except:
    # handle all exceptions, including Thing


More information about the Python-Dev mailing list