[3.9] bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332) by pablogsal · Pull Request #23333 · python/cpython · GitHub
Skip to content

[3.9] bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332) - #23333

Merged
pablogsal merged 1 commit into
python:3.9from
pablogsal:backport-b0aba1f-3.9
Nov 18, 2020
Merged

pablogsal merged 1 commit into
python:3.9from
pablogsal:backport-b0aba1f-3.9

Conversation

@pablogsal

@pablogsal pablogsal commented Nov 17, 2020

Copy link
Copy Markdown
Member

{y := 4, 42, 33}
File "", line 1
{y := 4, 42, 33}
^
SyntaxError: invalid syntax

but they should be allowed as well per PEP 572.
(cherry picked from commit b0aba1f)

Co-authored-by: Pablo Galindo Pablogsal@gmail.com

https://bugs.python.org/issue42381

…ythonGH-23332)

Currently walruses are not allowerd in set literals and set comprehensions:

>>> {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.
(cherry picked from commit b0aba1f)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@GPHemsley

Copy link
Copy Markdown
Contributor

@pablogsal

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants