Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Nov 17, 2020

{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>
Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

Yes!

@GPHemsley
Copy link
Contributor

Doesn't backporting this to 3.9 mean that code that works with 3.9.1 would throw a syntax error in 3.9.0?

@pablogsal
Copy link
Member Author

Doesn't backporting this to 3.9 mean that code that works with 3.9.1 would throw a syntax error in 3.9.0?

Yep, but precisely because if that is not backwards incompatible. No code that works in 3.9.0 will be broken in 3.9.1

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