Hands-on · Example-driven · No fluff
Python patterns explained with working code
Each tutorial here starts with a real problem, shows exactly what the language feature does to solve it, and explains the tradeoffs so you know when to reach for it again. No slides, no quiz questions, no filler.
Latest tutorials
All tutorials →-
Built-ins
enumerate() and zip() in Python: Loop Over Multiple Sequences Cleanly
enumerate() adds an index counter without range(len()), and zip() pairs sequences in lockstep. Together they cover nearly every parallel-iteration pattern.
-
Data Structures
Sets and Frozensets in Python: Unordered Collections with Powerful Maths
Sets hold only unique values and support O(1) membership testing. Covers set arithmetic operators, set comprehensions, and frozensets for hashable immutable needs.
-
Functions
*args and **kwargs in Python: Flexible Function Signatures Explained
Collecting variable positional and keyword arguments, unpacking sequences and dicts at the call site, and keyword-only parameter syntax.
-
Standard Library
Regular Expressions in Python: Patterns, Groups, and the re Module
Pattern syntax, search vs match, capturing groups, named groups, flags, substitution, and when NOT to reach for regex.
-
Resource Management
Context Managers in Python: with Statements and the Protocol Behind Them
The __enter__/__exit__ protocol, writing your own manager as a class or with contextlib.contextmanager, and suppressing exceptions cleanly.
-
Modern Python
Type Hints in Python: Annotate Code Without Changing Its Behaviour
Optional annotations that static checkers and IDEs use to catch bugs. Covers Optional, Union, generics, and what happens at runtime.
-
Data Structures
Dictionary Techniques in Python: Beyond Basic Key-Value Storage
Dict comprehensions, defaultdict, safe access with get() and setdefault(), the | merge operator, and Counter for frequency counting.
-
Standard Library
Working with Files in Python: Reading, Writing, and Paths
Open modes, line-by-line iteration, pathlib for path manipulation, and why the with statement is the only safe way to handle file objects.
-
Error Handling
Exception Handling in Python: try, except, else, finally
Catching specific types, the role of else and finally, raising meaningful errors, and building a custom exception hierarchy.
-
Core Syntax
f-Strings Formatting: Everything You Can Put Inside the Braces
Beyond variable interpolation: alignment, number specs, debug output with =, and the full format mini-language inside curly braces.
-
Tooling
Virtual Environments with venv: Project Isolation Step by Step
Each project gets its own dependency tree. How to create, activate, install into, and reproduce a venv environment reliably.
-
Iterators
Generators and yield: Sequences That Pay as They Go
Why loading a million rows into a list is unnecessary. How yield pauses a function and resumes it on demand, keeping memory flat.
-
Functions
Decorators Explained: Wrap Functions Without Touching Them
How decorators borrow function objects, add behaviour around them, and return a modified callable. Built step by step from first principles.
-
Core Syntax
List Comprehensions: Build Lists Without the Loop Noise
Transform, filter, and flatten sequences in one readable expression. When comprehensions help and when a plain loop is the better choice.
What this site covers
Comprehensions, generators, decorators, context managers, and the other features that separate readable Python from verbose Python.
File I/O, regular expressions, collections, and pathlib. The batteries that are already included, shown in context you will actually encounter.
Type hints, f-strings, virtual environments, and the conventions that make code easier to read, test, and hand off to other people.