What c.l.py's opinions about Soft Exception?

Diez B. Roggisch deets at nospam.web.de
Tue Mar 11 03:50:37 EDT 2008


Chris schrieb:
> If all you wanted was some grouping of exceptions why not something
> like...
> 
> soft_exception_list = [IndexError, TypeError]
> hard_exception_list = [ZeroDivision]
> 
> try:
>     do_something()
> except Exception, e:
>     if e.__class__ in soft_exception_list:
>         handle_soft_exception()
>     elif e.__class__ in hard_exception_list:
>         handle_hard_exception()
>     else:
>         raise NotImplementedError
> 
> Granted you're most likely looking for something that does this
> constantly on every line of code though...

It's not about grouping, which would be done better with inheritance by 
the way.

Its about not raising certain exceptions if there is no handler.

Diez



More information about the Python-list mailing list