Settings

Theme

PEP 798 – Unpacking in Comprehensions

peps.python.org

7 points by asicsp 5 months ago · 2 comments

Reader

Daishiman 5 months ago

This is very nice. The syntax occurs in ways that are consistent with how it's used elsewhere. The desugaring is clear. No weird gotchas. The proposed use cases are very common and actually suffer from there being "more than one way to do it", which goes against the grain of the language. The proposal seems clearer, more concise, and more idiomatic than the alternatives.

I will say that even after using Python for over 15 years, the syntax for nested list comprehensions has a rather... incomprehensible order.

  • asicspOP 5 months ago

    >the syntax for nested list comprehensions has a rather... incomprehensible order

    I remember reading a blog post pointing out that the for-loop order stays the same between comprehensions and normal nested code. You write the outer loop first.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection