Python📜History & Evolutionbeginner
Python 2.0 — List Comprehensions & Unicode (2000)
Python · History & Evolution · Run with python3
Explanation
Python 2.0 was released on October 16, 2000. It introduced list comprehensions (borrowed from Haskell), a garbage collector for cyclic references, Unicode strings, and the `zip()`, `map()`, and `filter()` builtins in their modern form. Crucially, the development process moved to open source with Sourceforge — marking Python's transition to true community governance.
Real-World Scenario
Before list comprehensions, building a filtered list required `filter()` + `lambda` or explicit `for` loops. `[x**2 for x in range(10) if x % 2 == 0]` reads as English — this readability philosophy became Python's signature trait.
Quick Snippet
snippet.py
# List comprehension (Python 2.0+) — revolutionary readability
squares = [x**2 for x in range(1, 11)]
evens = [x for x in range(20) if x % 2 == 0]
matrix_flat = [cell for row in [[1,2],[3,4]] for cell in row]
print(squares[:5]) # [1, 4, 9, 16, 25]Full Example
python2_features.py
# Compile: python3 python2_features.py
# Output:
# [1, 4, 9, 16, 25]
# [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
# [1, 2, 3, 4]
# List comprehension (introduced Python 2.0)
squares = [x**2 for x in range(1, 6)]
print(squares)
# Filtered comprehension
evens = [x for x in range(20) if x % 2 == 0]
print(evens)
# Nested comprehension — flatten a 2D matrix
matrix = [[1, 2], [3, 4]]
flat = [cell for row in matrix for cell in row]
print(flat)
Run command
python3 python2_features.py