[Python-ideas] decorator syntax limitation

Jan Kaliszewski zuo at chopin.edu.pl
Thu Feb 20 22:55:28 CET 2014


20.02.2014 22:31, Franck Michea wrote:

> Today I hit a limitation of decorator syntax, and I was wondering if
> maybe this limitation could be removed, or if they could allow more.
>
> The grammar for decorators is[1]:
>
>     decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
>
> But `dotted_name` doesn't allow to write things like the comment put 
> in
> the snippet attached, or this smaller snippet:
>
>     @M(b).decorator()
>     def wrapped_func():
>         pass
>
> Although it looks possible to me to add this syntax, I was wondering
> if it had been discussed previously, and if I could see that
> discussion.
>
> All discussions I found were a lot older, arround the time decorators
> were designed and the syntax was being choosen. I also read PEP306 
> and
> PEP318.
>
> This is not a blocking issue since you can do with a temporary
> variable, but I was wondering what were your thoughts on this.

AFAIR, there was some discussion a year or a few years ago --
unfortunately I don't remember the details (of course it must be
in archives of python-ideas (or maybe python-dev?)).

As far as I remember, generally, the belief that this restriction
is necessary seemed not to be very strong.

Cheers.
*j



More information about the Python-ideas mailing list