[Python-Dev] Decorator syntax J2 (decorate..def), with implementation

Phillip J. Eby pje at telecommunity.com
Mon Aug 16 03:26:13 CEST 2004


At 08:19 PM 8/15/04 -0400, Barry Warsaw wrote:
>On Sun, 2004-08-15 at 19:58, Nick Coghlan wrote:
>
> > What about the variant which makes the block optional when there is only
> > one decorator?
>
>Better, but I'm still not crazy about it, mostly because of the new
>keyword.  I think you'd have to add an __future__ to get it into Python
>2.4.

A slight variation of the J4 syntax could allow a single-decorator variant 
to look like:

     def foo(cls,bar) @classmethod as:
         # code here

versus this for multiple decorators:

     def foo(cls,bar)
         @classmethod
         @synchronized
     as:
         # code here

Neither variant needs a new keyword or __future__.



More information about the Python-Dev mailing list