Skip to content

Advanced Python ​

You have used @property, with, and @pytest.mark.parametrize. This track shows how they work and how to write your own.

This track is for people who finished the main course or already write Python regularly. It has eight lessons and one project. The format is the same as the main course: runnable examples, common mistakes with real error output, exercises with solutions, and a checkpoint quiz at the end.

Start with Closures and Decorators → · Back to the main course

What you should already know ​

The lessons build on these topics from the main course. If one is unfamiliar, read that lesson first.

Lessons ​

LessonYou'll be able to
Closures and DecoratorsWrite decorators with functools.wraps, give them arguments, and stack them
The Python Data ModelExplain how attribute lookup, __slots__, and the descriptors behind property work
Context Managers in DepthWrite class-based context managers and manage several resources with ExitStack
Async and awaitRun coroutines concurrently with gather and TaskGroup, and tell when async helps
Memory and PerformanceMeasure time and memory with timeit, tracemalloc, and cProfile before you optimize
Pythonic Design PatternsUse strategies, factories, registries, and observers the way Python code usually writes them
Threads and ProcessesChoose between threads, processes, and asyncio for I/O-bound and CPU-bound work
Testing in DepthOrganize a test suite with fixtures, monkeypatch, and unittest.mock
Project: Log PipelineCombine generators, decorators, context managers, and async in one program with tests

Go in order if you can. The project comes last because it uses something from almost every lesson before it.

What you need ​

Most examples run in the browser, like the rest of the site. A few do not: the site's editor cannot start threads or processes, so Threads and Processes asks you to run its examples on your own computer, and some examples in the performance and testing lessons do the same. Those lessons say so where it applies. Installing Python covers the setup.