Python and checked exceptions

Peter Otten __peter__ at
Sat Sep 23 13:51:28 CEST 2006

Kay Schluehr wrote:

> A new cookbook recipe suggesting two decorators @throws and @catches
> for treatment of checked exceptions in Python:
> This might be of practical interest for some and theoretical interest
> for others - in particular those who know checked ex as a language
> feature of Java.

Probably not what you wanted:

>>> test()
Raises UncheckedExceptionError(exceptions.ZeroDivisionError) -> OK
Raises ZeroDivisionError -> OK
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "", line 134, in test
UnboundLocalError: local variable 'test4' referenced before assignment


More information about the Python-list mailing list