[issue32012] Disallow ambiguous syntax f(x for x in [1],)

Nick Coghlan report at bugs.python.org
Tue Nov 14 05:28:28 EST 2017


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I created https://bugs.python.org/issue32023 to explicitly cover the base class list case, and after checking the language spec, I agree that case should be a syntax error.

However, `@deco(x for x in [])` should *not* be a syntax error, as:

* it's a call with one argument, so the genexp parentheses can be omitted as described in https://docs.python.org/3/reference/expressions.html#generator-expressions
* it matches the "@dotted_name(arg_list)" pattern permitted by https://docs.python.org/3/reference/compound_stmts.html#function-definitions

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32012>
_______________________________________


More information about the Python-bugs-list mailing list