[Python-Dev] Re: new syntax for wrapping (PEP 318)

Barry Warsaw barry at python.org
Thu Feb 26 20:58:43 EST 2004


On Thu, 2004-02-26 at 18:43, Delaney, Timothy C (Timothy) wrote:

> This isn't too bad. Probably better with a wrapper around sys.atexit -
> something like:
> 
>     def atexit (func):
>         sys.atexit(func)
>         return func
> 
>     def cleanup() [atexit]:
> 
> otherwise it's not obvious that cleanup gets bound to None. Perhaps it
> should be a requirement of decorators that they return something other
> than None, and an exception is thrown if this contract is broken?

Would it be better if it returned 1? <wink>

Just what /is/ the contract for a decorator function?  Maybe that it
takes a function/method object and must return a descriptor?  I do think
this needs some clarification in the PEP.

-Barry





More information about the Python-Dev mailing list