On one hand we have
- List comprehension
[x for x in range(10)]
- Set comprehension
{x for x in range(10)}
- Dict comprehension
{x: x for x in range(10)}
On the other we have
- Generator expression
(x for x in range(10))
Why are the first three expressions called "comprehensions", while the last one is called "expression"? They are represented almost in the same way, and I guess they also work in a very similar way. Is there any subtle reason behind it? It's just for the sake of curiosity.
References: