[Python-ideas] The way decorators are parsng

Guido van Rossum guido at python.org
Thu Oct 20 04:20:58 CEST 2011


On Wed, Oct 19, 2011 at 3:36 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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).

If this gets changed we won't be able to give a different meaning to e.g.

@(...)
@[...]
@{...}

since those will all have to be accepted as valid forms of the syntax

@<expr>

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list