[issue19660] decorator syntax: allow testlist instead of just dotted_name

James Powell report at bugs.python.org
Wed Nov 20 02:27:05 CET 2013


New submission from James Powell:

Decorator syntax currently allows only a dotted_name after the @. As far as I can tell, this was a gut-feeling decision made by Guido. [1]

I spoke with Nick Coghlan at PyTexas about this, and he suggested that if someone did the work, there might be interest in revisiting this restriction.

The attached patch allows any testlist to follow the @.

The following are now valid:

@(lambda x:x)
def f():
    pass

@(spam if p else eggs)
def f():
    pass

@spam().ham().eggs()
def f():
    pass

[1] http://mail.python.org/pipermail/python-dev/2004-August/046711.html

----------
components: Interpreter Core
messages: 203456
nosy: james
priority: normal
severity: normal
status: open
title: decorator syntax: allow testlist instead of just dotted_name
type: enhancement
versions: Python 3.4, Python 3.5

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


More information about the Python-bugs-list mailing list