How to except the unexpected?

Alex Martelli aleaxit at yahoo.com
Sat Mar 4 22:22:50 CET 2006


James Stroud <jstroud at ucla.edu> wrote:

> > Reraise = (LookupError, ArithmeticError, AssertionError) # And then some
> > 
> > try:
> >     process_things()
> > except Reraise:
> >     raise
> > except:
> >     log_error()
> > 
> 
> Why catch an error only to re-raise it?

To avoid the following handler[s] -- a pretty common idiom.


Alex



More information about the Python-list mailing list