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

Guido van Rossum report at bugs.python.org
Tue Nov 14 13:00:03 EST 2017


Guido van Rossum <guido at python.org> added the comment:

It's a (small) mistake that we didn't make the syntax for argument lists in decorators the same as argument lists everywhere else, and that should be fixed to allow exactly what's allowed in regular calls. (That syntax is weird because we don't want e.g. `@foo().bar` but we do want e.g. `@foo.bar()`.)

I am honestly not sure that we should change anything here, since the meaning is not actually ambiguous: the syntax for generator expressions doesn't allow e.g. `x for x in 1, 2, 3` -- you have to write `x for x in (1, 2, 3)`. (A regular for-loop *does* allow this, but there the context makes it unambiguous -- that's why genexprs are different.)

But I'm fine with changing it, as long as we do it consistently.

----------

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


More information about the Python-bugs-list mailing list