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

[3.9] bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332)#23333
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

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
Copy Markdown
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