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

Chris cwitts at gmail.com
Tue Mar 11 07:52:50 CET 2008


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...



More information about the Python-list mailing list