Python Fundamentals
Start with Python's history, then master the core language — types, functions, classes, and decorators.
Birth of Python (1989–1991)
Python was created by Guido van Rossum during the Christmas holidays of 1989 at ...
Python 2.0 — List Comprehensions & Unicode (2000)
Python 2.0 was released on October 16, 2000. It introduced list comprehensions (...
Python 3.0 — The Great Divide (2008)
Python 3.0 ("Py3k") was released December 3, 2008. It deliberately broke backwar...
The 2-to-3 Migration (2008–2020)
For 12 years, Python 2 and Python 3 coexisted. The migration tools (`2to3`, `six...
CPython and Alternative Runtimes
CPython is the reference implementation — the C-based interpreter that Guido cre...
Python 3.10 — Structural Pattern Matching (2021)
Python 3.10 introduced `match`/`case` (PEP 634), the most syntactically signific...
Python 3.11 — Faster CPython (2022)
Python 3.11 delivered the first fruits of the "Faster CPython" project (funded b...
Python 3.12–3.13 — JIT and Free-Threading (2023–2024)
Python 3.12 (Oct 2023) improved f-strings (arbitrary expressions inside), added ...
Variables and Types
Python is dynamically typed — a variable is just a name bound to an object; the ...
Control Flow
Python's control flow uses `if`/`elif`/`else`, `for` (iterating any iterable), `...
Functions — *args, **kwargs, and Defaults
Python functions support positional args, keyword args, defaults, variadic posit...
Lambda Functions
`lambda` creates an anonymous single-expression function. It's syntactically lim...
Comprehensions
Python has four comprehension forms: list `[expr for x in it if cond]`, dict `{k...
Generators and the `yield` Keyword
A generator function uses `yield` instead of `return` — calling it returns a gen...
Decorators
A decorator is a callable that takes a function and returns a (usually modified)...
Classes and Object-Oriented Programming
Python uses class-based OOP with dynamic dispatch. `__init__` is the initializer...
Inheritance and MRO
Python supports multiple inheritance. The Method Resolution Order (MRO) determin...
Dunder (Magic) Methods
Dunder methods (`__method__`) let classes integrate with Python's built-in opera...
Context Managers and `with`
The `with` statement guarantees cleanup code runs even if exceptions occur. Any ...
Exception Handling
Python exceptions are objects that inherit from `BaseException`. The hierarchy: ...
Iterables, Iterators, and the Iterator Protocol
Python's `for` loop works on any *iterable* — an object that implements `__iter_...
Type Hints (PEP 484)
Python 3.5 introduced type hints via PEP 484. They are not enforced at runtime —...
Walrus Operator `:=` (Python 3.8+)
The walrus operator (`:=`, PEP 572) assigns a value to a variable and returns it...
Structural Pattern Matching (`match`/`case`, Python 3.10+)
`match`/`case` (PEP 634) is not a simple switch — it performs structural decompo...
Dataclasses (Python 3.7+)
`@dataclass` auto-generates `__init__`, `__repr__`, `__eq__` (and optionally `__...