classification
Title: unintended syntax error with decorators, parenthesis, and dots?
Type: compile error Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.5.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: LambertDW, erickt, georg.brandl
Priority: normal Keywords:

Created on 2008-11-14 06:03 by erickt, last changed 2008-11-14 18:06 by georg.brandl. 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) * (Python committer) 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
2008-11-14 18:06:43georg.brandlsetstatus: open -> closed
resolution: wont fix
messages: + msg75879
nosy: + georg.brandl
2008-11-14 06:44:15LambertDWsetnosy: + LambertDW
messages: + msg75852
2008-11-14 06:03:30ericktcreate