RELEASED Python 2.4, alpha 2

Christopher T King squirrel at WPI.EDU
Thu Aug 5 15:09:48 EDT 2004


On Thu, 5 Aug 2004, David Eppstein wrote:

> Let me get this straight: you're envisioning a situation in which you 
> want to decorate a function, the decorator might fail, and if it does 
> you want to do something else (perhaps including not decorating it at 
> all), but with the same function body?

Correct.

> If so, that's easy:
> 
> def my_robust_decorator(func):
>     try:
>         return decorator_that_might_fail(func)
>     except:
>         return something_else
> 
> @my_robust_decorator
> def func(args...):
>    ....

Well, you've found a good solution.  I stand corrected.




More information about the Python-list mailing list