← Learn
Learn · Python

Python advanced

Eleven lessons on how Python really works and what experienced developers reach for: names and copies, inheritance and composition, special methods and dataclasses, iterators and generators, functions as values, decorators, context managers, type hints, threads, processes and asyncio, and setting up real projects that stay fast.

Part of the Python developer path.

Take first: Python intermediate.

  1. Before you start

    A recap of what this course builds on: dicts, sets, comprehensions, exceptions, modules and classes.

    4 questions
  2. Names, objects and copies

    How variables really work: names point at objects, mutation vs rebinding, is vs ==, copies, and what functions receive.

    6 questions
  3. Inheritance and composition

    Building one class on another, overriding methods, super(), isinstance(), and when to hold an object instead.

    6 questions
  4. Special methods and dataclasses

    Making your objects work with ==, <, len(), + and print using dunder methods, then letting @dataclass write them.

    6 questions
  5. Iterators and generators

    What a for loop really does, writing generators with yield, lazy generator expressions, and itertools.

    6 questions
  6. Functions as values

    Passing functions around: lambda, sorting with key, map and filter, closures, and functools (partial, reduce, cache).

    6 questions
  7. Decorators

    Wrapping functions to add behaviour: how @ works, writing a decorator, functools.wraps, and decorators that take options.

    6 questions
  8. Context managers

    What with really does, writing your own with __enter__ and __exit__ or @contextmanager, and the handy ones built in.

    6 questions
  9. Type hints

    Annotating what types functions take and return, the common forms, Protocols, and checking them with a type checker.

    6 questions
  10. Concurrency and asyncio

    Doing several things at once: threads for waiting, processes for heavy maths, the GIL, and async and await.

    6 questions
  11. Real projects and speed

    Virtual environments, pyproject.toml, project layout, logging, and measuring and fixing slow code.

    6 questions
More info

How it works

Each lesson is a short read with examples, then a few practice questions. Some ask you to type an answer (a number, an address, what a piece of code prints), some have you pick one, and some have you tap steps or lines into the right order. You can try again as often as you like; after two misses there’s a button to show the answer.

What do I need to know first?

Python intermediate, or the same ground elsewhere: dicts, comprehensions, exceptions, modules and simple classes. The first lesson recaps what it uses.

Related courses

Where is my progress saved? In this browser, like the rest of the site. Nothing to sign up for.

“Python” is a registered trademark of the Python Software Foundation. This course isn’t made by or affiliated with it.