What PEP introduced list comprehensions back to Python 2.0?
Answer
PEP 202
Answer
PEP 202
PEP 202 introduced list comprehensions to Python 2.0.
The proposal was written by Barry Warsaw and created on July 13, 2000. It added a compact syntax for constructing lists from an iterable, optionally filtering items: `[x for x in values if condition]`. The feature became part of the Python language with the Python 2.0 release.
PEP 202’s motivation was to express work commonly performed with loops, `map()`, and `filter()` more concisely. It also specified how multiple `for` and `if` clauses nest, with the final loop varying fastest—matching the behavior of nested loops.
List comprehensions continued into Python 3, where they are widely used, but their scoping behavior changed. In Python 2, the loop variable could leak into the surrounding scope; in Python 3, the comprehension has its own implicit scope. PEP 206 concerns an entirely different proposal, while PEP 204 and PEP 205 were not the proposal that introduced this feature.
Source: Wikipedia · fact-checked Aug. 2026