[New-bugs-announce] [issue4321] unintended syntax error with decorators, parenthesis, and dots?

Erick Tryzelaar report at bugs.python.org
Fri Nov 14 07:03:31 CET 2008


New submission from Erick Tryzelaar <idadesub at users.sourceforge.net>:

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

----------
components: Interpreter Core
messages: 75850
nosy: erickt
severity: normal
status: open
title: unintended syntax error with decorators, parenthesis, and dots?
type: compile error
versions: Python 2.5.3, Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4321>
_______________________________________


More information about the New-bugs-announce mailing list