ThePythonBook

Advanced Python

Iterators, generators, decorators, type hints, async, and internals

12tutorials
72exercises
330minutes
1310XP
12 tutorials in this category

Python Iterators: How for Loops Really Work Under the Hood

How for loops actually work under the hood. The iterator protocol, __iter__, __next__, StopIteration, and building your own.

advanced25m6105

Python Generators: Process Millions of Items Without Running Out of Memory

Process huge datasets without running out of memory. yield, generator expressions, and lazy evaluation in practice.

advanced30m7125

Python Decorators Explained: A Step-by-Step Guide

Wrap functions to add behavior — logging, timing, caching, access control. Step-by-step from closures to @decorator syntax.

advanced30m8145

Python Type Hints: Add Types, Generics, and the typing Module

Add type annotations to your Python code. int, str, List, Optional, Union, generics, and catching bugs before runtime with mypy.

intermediate25m695

Python Protocols: Duck Typing with Type Safety

Structural typing for Python — define interfaces without inheritance. If it walks like a duck and types like a duck...

advanced25m5100

Python Pydantic: Validate Data Like a Pro

Validate and parse data with type annotations. BaseModel, field validators, serialization, and catching bad data at the boundary.

advanced25m6120

15 Python Pitfalls That Trip Up Even Experienced Developers

Mutable default arguments, late binding closures, integer caching, and other gotchas that trip up even experienced Python developers.

intermediate25m7105

Python Threading vs Multiprocessing vs asyncio: When to Use What

Threading for I/O, multiprocessing for CPU, asyncio for many connections. Know which tool fits which problem.

advanced30m5100

Python Async/Await: Write Non-Blocking Code from Scratch

Write non-blocking code with async/await. Coroutines, the event loop, asyncio.gather, and real-world async patterns.

expert30m6120

Python Design Patterns: Factory, Strategy, Observer, and More

Factory, Strategy, Observer, Singleton, and more — classic patterns translated into idiomatic Python.

advanced30m6120

How Python Works Under the Hood: Memory, GIL, and Bytecode

Peek under the hood: CPython, bytecode, the GIL, reference counting, garbage collection, and how memory actually works.

expert30m5100

Build Command-Line Tools with argparse and sys.argv

Build command-line programs with argparse and sys.argv. Parse flags, add help text, and make your scripts user-friendly.

intermediate25m575