[Python-Dev] Decorator syntax

Eric Smith eric at trueblade.com
Wed Sep 2 18:11:48 CEST 2009

Erik Bray wrote:
> I think Guido may have a point about not allowing any arbitrary
> expression.  But I do think that if it allows calls, it should also at
> least support the itemgetter syntax, for which there seems to be a
> demonstrable use case.  But that's just adding on another special
> case, so it might be simpler to allow arbitrary expressions.

It's not the same issue, of course, but note that str.format's object 
specification "language" supports item and attribute access. And that's 
the extent of what it allows.

If you wanted to do this for decorators, I'm not sure how easy it would 
be to restrict the expression inside the brackets, or if you'd even want 
to. str.format has all of this baked-in, it doesn't use any sort of grammar.


More information about the Python-Dev mailing list