🐍 Learn Python — From Zero to Pro

A comprehensive, edge-case-covering, idiomatic Python curriculum. Each document is self-contained and covers its concept deeply enough that a careful reader can go from beginner to pro Python developer.

How to Use This Course

  1. Read sequentially for a structured path (01 → 28).
  2. Jump to a chapter as a reference when you hit a concept in the wild.
  3. Run every example in a REPL or script as you read — Python rewards experimentation.
  4. Do the exercises in chapter 28 after every few chapters, not just at the end.
  5. Read the CPython source and the standard library alongside once you reach Part IV.

Prerequisites

  • A working Python 3.11+ installation (managed via pyenv is recommended — see chapter 01).
  • A code editor (VS Code + Pylance, or PyCharm).
  • Comfort with at least one other programming language helps but isn't required.

Curriculum

Part I — Foundations

#TopicWhy It Matters
01Introduction & SetupCPython vs PyPy, pyenv, the REPL, .py vs .pyc.
02Variables & Data TypesDynamic typing, int/float/bool/str/None, duck typing.
03Operators & ExpressionsArithmetic, is vs ==, chained comparisons, the walrus operator.
04Control Flowif/while/for, loop else, structural pattern matching (match/case).
05Functionsdef, *args/**kwargs, the mutable default argument trap.
06Strings & Textstr methods, f-strings, encodings, bytes vs str, re.
07Lists & TuplesMutability, slicing, comprehensions, packing/unpacking, copy/deepcopy.
08Dictionaries & SetsInsertion order, hashing, defaultdict, Counter, set algebra.
09Comprehensions & GeneratorsAll four comprehension forms, yield, yield from, itertools.

Part II — Functions & OOP

#TopicWhy It Matters
10Functional Programminglambda, map/filter/reduce, functools (partial, lru_cache, wraps).
11Closures & Decoratorsnonlocal, writing decorators, parameterized decorators.
12Classes & Objects__init__, instance vs class attributes, self, dunder overview.
13Inheritance & PolymorphismMRO/C3 linearization, super(), abstract base classes.
14Magic Methods & Protocols__eq__/__hash__, __getitem__/__iter__, context managers.
15Properties & Descriptors@property, the descriptor protocol, __slots__.

Part III — Error Handling & Modules

#TopicWhy It Matters
16Error Handlingtry/except/else/finally, exception hierarchy, raise ... from.
17Modules & PackagesImport system, __init__.py, circular imports, __name__ == '__main__'.
18File I/O & Serializationopen() modes, pathlib, json/pickle/csv, encoding pitfalls.

Part IV — Advanced Language Features

#TopicWhy It Matters
19Iterators & Context ManagersThe iterator protocol, contextlib, itertools deep dive.
20Type Hints & Typingtyping, generics, Protocol, TypedDict, mypy.
21Concurrency: Threading & MultiprocessingThe GIL, threading, multiprocessing, race conditions.
22Async / AwaitThe event loop, coroutines vs tasks, asyncio.gather, pitfalls.
23MetaprogrammingMetaclasses, __new__, class decorators, __getattr__.

Part V — Production Engineering

#TopicWhy It Matters
24Testingunittest vs pytest, fixtures, mocking, parametrization, coverage.
25Packaging & Virtual Environmentsvenv, pip, pyproject.toml, uv/poetry, publishing to PyPI.
26Performance & OptimizationcProfile, memory views, __slots__, when to reach for C extensions.
27Securitypickle risks, eval/exec dangers, SQL injection, secrets.
28Exercises & ProjectsCapstone projects from beginner to advanced.

Learning Path Suggestions

If you're new to programming

Read 01–09 slowly, running every example. Don't skip the Edge Cases sections — Python's forgiving syntax hides real mechanics (mutability, references, truthiness) that will confuse you later if skipped now. Do the beginner exercises in chapter 28 after chapter 09, then continue to Part II.

If you're coming from JavaScript

Skim 01–04 (similar shape, different keywords: elif, None, no var/let distinction — Python has no block scope). Pay close attention to 05 (default argument mutation is a Python-specific trap JS doesn't have), 07–08 (Python's list/dict semantics around copying and mutation differ from JS arrays/objects), and 21–22 (the GIL means Python's concurrency story is fundamentally different from Node's single-threaded event loop). Don't assume == behaves like JS — read 03 carefully.

If you're coming from a statically-typed language (Java, C#, Go)

Python's duck typing (02) and dynamic dispatch will feel unfamiliar at first — lean into it rather than fighting it with excessive isinstance checks. Read 20 (Type Hints) early to get static-analysis safety back via mypy. Read 13–15 for how Python does OOP differently (multiple inheritance via MRO, properties instead of getters/setters, duck-typed protocols instead of explicit interfaces).

If you have a data science background (pandas/numpy but shaky on "core" Python)

You likely know 02, 04, 07–08 already — skim them for gaps (slicing edge cases, the is/== distinction). Focus on 05, 09–11 (comprehensions and generators are everywhere in idiomatic pipeline code), 16 (proper exception handling instead of bare except:), 19 (iterators/context managers explain why with open(...) and generators in pandas/numpy code work the way they do), and 26 (performance — vectorization vs Python loops, memory views).

Companion Resources

Tooling to Install

bash
# Python version management
curl https://pyenv.run | bash
pyenv install 3.12.4
pyenv global 3.12.4

# Fast, modern package/project manager (installs Python too)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Linting, formatting, static typing, testing
pip install ruff mypy pytest pytest-cov ipython

License

These notes are yours to use, share, and modify.

🐍