Python and checked exceptions

Kay Schluehr kay.schluehr at gmx.net
Sat Sep 23 09:56:50 EDT 2006


Peter Otten wrote:
> Kay Schluehr wrote:
>
> > A new cookbook recipe suggesting two decorators @throws and @catches
> > for treatment of checked exceptions in Python:
> >
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498131
> >
> > 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 "checked_exceptions.py", line 134, in test
>     test4(3,2)
> UnboundLocalError: local variable 'test4' referenced before assignment
> 
> Peter

Thanks, I fixed this.

Kay




More information about the Python-list mailing list