Python Forum
if <expr> as <name> syntax interest
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if <expr> as <name> syntax interest
#3
Thanks for the link! That covers my use cases, although I prefer as over :=...

Apparently why they didn't use as over := is discussed here: https://www.reddit.com/r/Python/comments...ly/e1pfzgv

Quick snippet:
Quote:The reason why they didn't is because this had to work in logical expressions, and from a parsing standpoint, it would be extremely difficult to determine the assignment expression in the context manager of a comprehension containing the expression, and the assignment of the context manager itself.
Reply


Messages In This Thread
if <expr> as <name> syntax interest - by Lucid - Jul-06-2018, 03:32 PM
RE: if <expr> as <name> syntax interest - by buran - Jul-06-2018, 03:38 PM
RE: if <expr> as <name> syntax interest - by Lucid - Jul-06-2018, 03:45 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020