New: Try Voli The Bear, Fast package manager (and not only) for Windows
All topics / Python From Zero

Python From Zero

Learn Python from nothing to genuinely advanced: install and the basics, then objects and tooling, then the deep half - the data model, generators, decorators, typing, concurrency and the GIL, performance, and packaging - all in small, runnable steps with clear explanations.

Download EPUB
  1. Install & Your First Program Install Python 3 on Windows, macOS, or Linux, confirm it works with python3 --version, try the interactive REPL, then write and run a hello.py file with python3 hello.py.
  2. Syntax, Values & Types Python uses indentation as structure (not braces), variables are names pointing at values, the core types are int/float/str/bool/None, f-strings format text, and typing is dynamic - plus the = vs == and integer-vs-float-division traps.
  3. Collections - Lists, Tuples, Dicts & Sets Python's four everyday collections: lists (ordered, changeable), tuples (ordered, fixed), dicts (key-to-value lookups), and sets (unique items) - how to index and slice them, which are mutable, and the aliasing trap where two names share one list.
  4. Control Flow & Functions Make programs decide with if/elif/else, repeat with for and while loops, and package reusable logic with def - parameters, defaults, and return values - plus truthiness and the classic mutable-default-argument trap.
  5. Modules & Project Layout Split code across files with import, pull in the standard library, write your own modules, understand the if __name__ == '__main__' guard, and lay out a small project so it stays sane as it grows.
  6. Objects & Classes - Python's OOP A class bundles data together with the behavior that acts on it; here's __init__, self, instances, methods, attributes, and inheritance - explained as one mental model, not a pile of keywords.
  7. Errors & I/O - Exceptions and Files Exceptions are Python's way of saying 'I can't continue' - here's try/except/finally, raise, reading and writing files with `with open(...)`, and why Python prefers asking forgiveness over asking permission.
  8. The Ecosystem & Tooling pip installs packages, virtual environments keep projects from poisoning each other, requirements.txt/pyproject.toml record what you depend on, and black/ruff/pytest keep your code clean and tested - the everyday toolbox, explained.
  9. Idioms & Common Gotchas The Pythonic idioms that make code read like a local wrote it - comprehensions, unpacking, enumerate/zip, truthiness, context managers - plus a cheat-card of the gotchas (mutable defaults, late-binding closures, is vs ==) that bite everyone exactly once.
  10. The Data Model & Dunder Methods Python's built-in syntax is secretly calling your methods: len(x) runs x.__len__(), a + b runs a.__add__(b), print(x) runs x.__repr__/__str__. Here's the data model - __repr__ vs __str__, __eq__ and __hash__, __getitem__/__iter__, and operator overloading - explained as one dispatch rule, not a list of magic names.
  11. Iterators & Generators Laziness is the big win: produce values one at a time instead of building a giant list. Here's the iterator protocol, generators with yield, generator expressions vs list comprehensions, and how to process a 10 GB file or an infinite sequence without loading it into RAM.
  12. Decorators The @ symbol stops being magic once you see what it really is - a decorator is just a function that takes a function and returns a wrapped one, and @decorator is sugar for f = decorator(f); here's the build-up, functools.wraps, decorators that take arguments, and where you've already been using them.
  13. Context Managers The with statement is Python's promise that setup gets a matching teardown - files close, locks release, transactions finish - even when an exception fires; here's the __enter__/__exit__ protocol and the easier @contextmanager generator behind it.
  14. Type Hints & mypy Python is dynamically typed, but gradual typing lets you annotate types and have a checker (mypy) catch a whole class of bugs before you ever run the code - without changing how the program runs.
  15. Dataclasses & Modern Modeling Writing __init__/__repr__/__eq__ by hand for a bag-of-fields class is pure boilerplate; @dataclass generates them from typed fields, field(default_factory=...) dodges the mutable-default trap, frozen=True gives you immutable hashable instances, NamedTuple is the lightweight alternative, and pydantic guards the boundary.
  16. Concurrency & the GIL Python gives you three tools - threading, multiprocessing, and asyncio - that solve different problems; here's the GIL explained straight (one thread runs Python at a time, but it's released during I/O), and the one decision rule that tells you which tool to reach for: I/O-bound → threads or asyncio, CPU-bound → multiprocessing.
  17. Performance & Memory Why Python is called 'slow' (interpreted + dynamic, so types are looked up at runtime), how CPython actually runs your code (source → bytecode → eval loop), how memory is freed (reference counting plus a cyclic garbage collector), and the one rule that matters - measure, don't guess - followed by the real speedups in the order that actually pays off.
  18. Packaging & Environments Turn a folder of scripts into something other people can pip install - virtual environments isolate per-project deps, pyproject.toml is the modern descriptor, python -m build makes a wheel, and twine/uv publish push it to PyPI.
  19. Where to Go Next A clear map of where Python goes from here - web (Django/FastAPI), data (pandas/NumPy), automation, and packaging - framed as signposts, not hype, with a nudge toward building something real.