[Python-Dev] pep 318, Decorators for Functions, Methods and Classes

Michael Hudson mwh at python.net
Thu Aug 12 12:39:35 CEST 2004


"Phillip J. Eby" <pje at telecommunity.com> writes:

> At 03:44 PM 8/11/04 -0400, Jack Diederich wrote:
>> I have a mostly working patch for class decorators but it gets an
>> XXX ambiguity
>>between
>>
>>funcdef: [decorators] 'def' NAME parameters ':' suite
>>and
>>classdef: [decorators] 'class' NAME [ '(' testlist ')' ] ':' suite
>>
>> It works as advertised with the pre-decorators funcdef definition
>> (which removes the ambiguity).
>>Help?
>
>
> How about this?
>
>      decorated_assignment: [decorators] (funcdef | classdef)

decorated_definition or something would be better surely?

>      classdef: 'class' NAME [ '(' testlist ')' ] ':' suite
>      funcdef: 'def' NAME parameters ':' suite

But yes, the answer to this problem is "left factoring", which google
can tell you all about...

Cheers,
mwh

-- 
  For their next act, they'll no doubt be buying a firewall 
  running under NT, which makes about as much sense as 
  building a prison out of meringue.                     -- -:Tanuki:-
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html


More information about the Python-Dev mailing list