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

Bob Ippolito bob at redivi.com
Sat Aug 14 01:24:24 CEST 2004


On Aug 13, 2004, at 7:31 PM, Michael Sparks wrote:

> Syntax option J2 from the wiki seems to have provoked an interesting
> discussion[1] at least by a small subset of c.l.p, so I wondered how
> difficult it would be to implement - this turned out to be relatively
> simple [2].
>    [1] 
> http://mail.python.org/pipermail/python-list/2004-August/233413.html
>    [2] 
> http://mail.python.org/pipermail/python-list/2004-August/233591.html
>        (implementation)
>
> #Syntax J2 from http://www.python.org/moin/PythonDecorators
> decorate:
>      staticmethod
>      grammarrule('statement : expression')
>      versioninfo("Added in 2.4")
>      deprecated
>      typeinfo(None)
> def p_statement_expr(self, p):
>      print p[1]

My only problem with this syntax is that I expect the common cases 
(mine, anyway) to be zero or one decorators per function, so the extra 
block and indent seems a bit excessive compared to the current 
@prefix-symbol-decorator proposal(s).  It is, of course, far better 
than typing the function name three times though! :)

-0

-bob


More information about the Python-Dev mailing list