[Python-ideas] Decorator syntax restriction

Nick Coghlan ncoghlan at gmail.com
Sun Sep 6 22:44:42 CEST 2009

Brett Cannon wrote:
> On Sun, Sep 6, 2009 at 09:41, Rob Cliffe<rob.cliffe at btinternet.com> wrote:
>> Can I make another plea for the syntax following '@' to be an unrestricted
>> expression?  Guido has said he has a 'gut feeling' against this but has not
>> as far as I know rationalised it.
> When it comes to Guido's gut, a rationalization isn't needed. Perk of
> being BDFL. Plus his gut is right so often it tends to not be
> questioned.
>> 1) It is inconsistent with Python in general (unPythonic) to impose
>> arbitrary restrictions in one particular place, and hard to explain to
>> someone learning the language.
> It's not difficult to explain; decorators can only be a dotted name w/
> an optional method call and its corresponding arguments.

>From the last discussion, I believe Guido was actually amenable to the
idea of extending this to allow a subscript operation as well, so a
decorator could be pulled from a sequence or map of decorators without
requiring an otherwise unnecessary function call.

So what's needed at this point is for someone that is bothered by the
restriction to come up with a patch to loosen the restriction without
getting rid of it entirely.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list