Issue 4321: unintended syntax error with decorators, parenthesis, and dots?
Created on 2008-11-14 06:03 by erickt, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg75850 - (view) | Author: Erick Tryzelaar (erickt) | Date: 2008-11-14 06:03 | |
I believe I found an unintentional syntax error with a combination of
decorators, parenthesis, and dots. Here's a demonstration:
class C:
def prop(self, function):
return property(function)
class F:
@C().prop
def foo(self):
return 5
Which errors out with:
File "foo.py", line 6
@C().prop
^
SyntaxError: invalid syntax
I can't imagine why this would be desired, since these equivalent forms
work:
class D:
def foo(self):
return 5
foo = C().prop(foo)
class E:
c = C()
@c.prop
def foo(self):
return 5
|
|||
| msg75852 - (view) | Author: David W. Lambert (LambertDW) | Date: 2008-11-14 06:44 | |
Guido gets to choose. Read PEP: 318 Title: Decorators for Functions and Methods and "gut feeling" http://mail.python.org/pipermail/python-dev/2004-August/046711.html |
|||
| msg75879 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2008-11-14 18:06 | |
Closing; changing this will at least need a python-dev discussion, and thorough motivation. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:41 | admin | set | github: 48571 |
| 2008-11-14 18:06:43 | georg.brandl | set | status: open -> closed resolution: wont fix messages: + msg75879 nosy: + georg.brandl |
| 2008-11-14 06:44:15 | LambertDW | set | nosy:
+ LambertDW messages: + msg75852 |
| 2008-11-14 06:03:30 | erickt | create | |
