En Fri, 09 Mar 2007 04:49:59 -0300, Gerard Flanagan  
<[EMAIL PROTECTED]> escribió:

> Another version:
>
> import exceptions

As back in time as I could go (Python 1.5), exceptions were available as  
builtins...

> def onfailFalse(fn):
>     def inner(*args, **kwargs):
>         try:
>             return fn(*args, **kwargs)
>         except ABCException:
>             return False
>     return inner
>
> @onfailFalse
> def a(x):
>     if x == 1:
>         return 'function a succeeded'
>     else:
>         raise ABCException()

There is a serious flaw on this approach, the function can't return any  
false value (it would be treated as a failure).

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to