[issue42381] Allow unparenthesized walrus in set comprehensions

Pablo Galindo Salgado report at bugs.python.org
Mon Nov 16 18:49:33 EST 2020


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

Apparently we currently don't allow walruses in set literals either:

>>> {y := 4, 4**2, 3**3}
  File "<stdin>", line 1
    {y := 4, 4**2, 3**3}
       ^
SyntaxError: invalid syntax

But they should be allowed as well per PEP 572 (as the pep mentions all comprehensions):

There is one special case: an assignment expression occurring in a list, set or dict comprehension or in a generator expression (below collectively referred to as "comprehensions") binds the target in ...

----------

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


More information about the Python-bugs-list mailing list