You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allowing arbitrary expressions in the @expression syntax #81377
Yes I read that. But I am wondering if after 15 years Guido still has this "gut feeling". Because my gut feeling as a Python *user* who has discovered decorators and stumbled on this restriction was: "what?!".
Activity
maggyero commentedon Jun 7, 2019
Could we allow arbitrary expressions in the @expression syntax for applying decorators to functions/classes? The current grammar restriction to:
is very surprising and I don't understand the real motivation.
I find it weird that you are not able to do that:
since you get:
but the following is perfectly valid:
See this post for more details: https://stackoverflow.com/questions/56490579
tiran commentedon Jun 7, 2019
The syntax is deliberately limited. The reasons are explained at:
https://www.python.org/dev/peps/pep-0318/#current-syntax
https://mail.python.org/pipermail/python-dev/2004-August/046711.html
maggyero commentedon Jun 7, 2019
@christian Heimes
Yes I read that. But I am wondering if after 15 years Guido still has this "gut feeling". Because my gut feeling as a Python *user* who has discovered decorators and stumbled on this restriction was: "what?!".
gvanrossum commentedon Jun 7, 2019
What you want to write is as unreadable as it ever was.
maggyero commentedon Jun 7, 2019
@guido van Rossum
How is @g(f()()) more readable than @f()()? Yet the former is allowed.