Python Quest

Learning map · Track 12 · advanced

Intermediate and Advanced Python

This track takes you from writing Python that works to writing Python that scales, reads well and reuses itself. You will look under the hood of the for loop and build your own iterators and generators, then chain them into lazy pipelines that stream through files and endless data without filling memory. You will learn how closures remember state, use them to write decorators for logging, validation, retries and caching, and guarantee clean-up with context managers. You will describe your data precisely with type hints, TypedDict, Protocol and generics, replace magic strings with enums, take data apart by shape with structural pattern matching, and combine functions with the functional tools in operator and functools. The track ends with asyncio: coroutines, the event loop, tasks, timeouts and queues, finishing with a concurrent job scheduler you build in four milestones.

It is written for learners who are comfortable with functions, data structures, errors, modules and classes (Tracks 1–11). Every feature comes with its practical value and its limits: when a list beats a generator, when a decorator hides too much, why type hints don't validate anything at runtime, why all([]) is True, and why async code does not help CPU-heavy work. Exercises use realistic contexts — invoices, inventories, sensor streams, payroll audits, supplier quotes — and every one is graded automatically, including hidden edge cases and debugging tasks that mirror real bugs: exhausted iterators, late-binding closures, wrappers that lose return values, swallowed exceptions and forgotten awaits.

By the end of this track you can

  • Write custom iterators and generators, and build lazy generator pipelines that process large or endless data in constant memory
  • Use closures and write decorators — including configurable, stacked and caching decorators — that preserve function metadata
  • Guarantee clean-up with context manager classes and contextlib, deciding deliberately which exceptions to suppress
  • Describe data with modern type hints, TypedDict, Protocol, generics, enums and structural pattern matching, while validating outside input at runtime
  • Compose data transformations with map, filter, key functions, operator, functools.partial and reduce, any/all and zip(strict=True)
  • Write concurrent asyncio programs with tasks, gather, TaskGroup, timeouts and queues, and judge when async, threads or processes fit a problem

Lessons

  1. 1Iterables and iteratorsHow a for loop really works: the iteration protocol, iter() and next(), StopIteration and writing your own iterator class.40 min · 4 exFree
  2. 2GeneratorsWrite iterators the short way with yield: lazy values, paused state, early stops and infinite sequences sliced with islice.45 min · 4 exMembers
  3. 3Generator expressions and pipelinesChain small lazy stages into data pipelines with generator expressions and yield from, and see why they use so little memory.45 min · 4 exMembers
  4. 4ClosuresNested functions that remember variables from where they were created: function factories, private state with nonlocal and the late-binding trap.40 min · 4 exMembers
  5. 5DecoratorsWrap functions to add logging, counting, validation and timing without touching their code, and understand what the @ syntax really does.45 min · 4 exMembers
  6. 6Decorators in depthKeep function metadata with functools.wraps, write decorators that take arguments, stack them in the right order and cache results with lru_cache.50 min · 4 exMembers
  7. 7Context managersGuarantee clean-up with the with statement: write __enter__ and __exit__, handle exceptions in __exit__, and use contextlib.contextmanager and suppress.50 min · 4 exMembers
  8. 8Type hints in depthDescribe data precisely with modern type hints — unions, None, nested collections, Callable, TypedDict, Protocol and generics — and know what hints do and don't do at runtime.50 min · 4 exMembers
  9. 9Enums and structural pattern matchingReplace magic strings with enum members, and take data apart by shape with match: class patterns, mapping patterns, guards and the capture-pattern trap.50 min · 4 exMembers
  10. 10Functional toolsWork with functions as building blocks: map and filter versus comprehensions, sorting with keys, the operator module, functools.partial and reduce, any/all and zip(strict=True).45 min · 4 exMembers
  11. 11asyncio basicsWhy programs wait, and how async def, await, asyncio.run and the event loop let one thread get on with other work while it waits.50 min · 4 exMembers
  12. 12asyncio concurrencyRun many coroutines at once with tasks, gather and TaskGroup; add timeouts, handle failures, coordinate workers with queues — and build an async job scheduler.90 min · 7 exMembers