Returning none

Bernhard Herzog herzog at online.de
Sat Sep 4 05:01:19 EDT 1999


clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) writes:

> def new_apply( f, a ):
>     try:
>         result = old_apply( f, a )
>     except NoResultError:
>         return
>     else:
>         return result

There's one problem with this approach. If the NoResultError is raised
whithin f, new_apply should reraise the exception and not just silently
return nothing.

You could, of course, examine the traceback object to find out where the
exception was raised, but that's very ugly and probably implementation
dependent.

-- 
Bernhard Herzog	  | Sketch, a drawing program for Unix
herzog at online.de  | http://www.online.de/home/sketch/




More information about the Python-list mailing list