Search code examples
pythonnaming-conventionslist-comprehension

Why is list comprehension called so in Python?


I know Python is not the first language to have list comprehension. I'm just interested in the history of the name.

I'm particularly interested in why it's called comprehension

Why is list comprehension called so in Python?


Solution

  • The name comes from the concept of a set-comprehension

    Comprehension is used here to mean complete inclusion or complete description. A set-comprehension is a (usually short) complete description of a set, not an exhaustive (and possibly infinite) enumeration.