[Python-Dev] Re: decorators and 2.4

Mark Russell marktrussell at btopenworld.com
Fri Jun 25 09:37:25 EDT 2004

On Wed, 2004-06-23 at 05:36, Guido van Rossum wrote:
>     @staticmethod
>     @funcattrs(vegetable="blag", author="GvR")
>     def blah2(args):
>         body
> I would love to see an implementation of this idea.

OK, here's my stab at it: python.org/sf/979728

It's fairly minimal - I guess the biggest impact change is that funcdef
is now defined in Grammar/Grammer as:

     decorator: '@' test [NEWLINE]
     decorators: decorator+
     funcdef: [decorators] 'def' NAME parameters ':' suite

As this version of funcdef has an optional element at the beginning, I
changed the funcdef child node references (in compile.c and
parsermodule.c) to use a new macro RCHILD() which takes a negative index
and treats it as relative to the end of the node's children array.  

Mark Russell

More information about the Python-Dev mailing list