PEP 798: Unpacking in Comprehensions

Rationale

[…]
This proposal was motivated in part by a written exam in a Python programming class, where several students used the notation (specifically the set version) in their solutions, assuming that it already existed in Python. This suggests that the notation is intuitive, even to beginners. By contrast, the existing syntax [x for it in its for x in it] is one that students often get wrong, the natural impulse for many students being to reverse the order of the for clauses.

16 Likes