[Python-ideas] The way decorators are parsng

Nick Coghlan ncoghlan at gmail.com
Thu Oct 20 00:36:10 CEST 2011


On Thu, Oct 20, 2011 at 7:52 AM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:
>> So, you're limited to an arbitrarily-long sequence of attribute
>> accesses, followed by an optional call.
>
> Thanks for the pointers

In the time since, Guido gave his approval to removing the
restriction, but nobody has been interested enough to actually
implement the change. He was persuaded the restriction was pointless
largely due to people using tricks like the following to avoid it:

def deco(x):
    return x

@deco(anything[I].like().can.go[here].and_the.compiler.will_not(care))
def f():
    pass

(There were also legitimate use cases related to looking up decorators
via a subscript rather than a function call).

Cheers,
Nick.

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



More information about the Python-ideas mailing list