suggestion for try/except program flow

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

Mark Donald wrote:
I frequently have this situation:
try: try: raise Thing except Thing, e: # handle Thing exceptions raise except: # handle all exceptions, including Thing
This seems like an unusual pattern. Are you sure you can't use
try: raise Thing except Thing, e: # handle Thing exceptions raise finally: # handle *all situations*, including Thing
Obviously, the finally: block is also invoked in the case that no exceptions are triggered, but often this is what you want anyway...
Michael
participants (2)
-
Mark Donald
-
Michael Haggerty