Issue 4321: unintended syntax error with decorators, parenthesis, and dots? (original) (raw)

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