Message344939
Could we allow arbitrary expressions in the @expression syntax for applying decorators to functions/classes? The current grammar restriction to:
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
is very surprising and I don't understand the real motivation.
I find it weird that you are not able to do that:
def f():
def g():
def h(x):
pass
return h
return g
@f()()
def i():
pass
since you get:
@f()()
^
SyntaxError: invalid syntax
but the following is perfectly valid:
def f():
def g():
def h(x):
pass
return h
return g
def g(x):
def h(x):
pass
return g
@g(f()())
def h():
pass
See this post for more details: https://stackoverflow.com/questions/56490579 |
|
Date |
User |
Action |
Args |
2019-06-07 14:05:15 | maggyero | set | recipients:
+ maggyero, mwh, gvanrossum, rhettinger, bob.ippolito, exarkun, j1m |
2019-06-07 14:05:15 | maggyero | set | messageid: <1559916315.57.0.952678742799.issue37196@roundup.psfhosted.org> |
2019-06-07 14:05:15 | maggyero | link | issue37196 messages |
2019-06-07 14:05:15 | maggyero | create | |
|