Python by topic

101 posts about Python, organized by topic rather than by date. Each topic links to its full archive, with the most recent posts listed to get you started.

Functions & parameters

Functions package reusable code, and parameters control what goes into them; these posts cover parameter types, keyword arguments, print's lesser-known options, and how functions work internally.

Objects & classes

Classes and objects organize data and behavior in Python, and these posts cover attribute lookup with ICPO, identity versus equality, __init__, and why object-oriented code is worth writing.

Strings & sequences

Strings, lists, and tuples share one sequence API in Python, and these posts cover slicing and reversing, str.join, raw strings on Windows, isdigit versus isnumeric, and the speed of concatenation and formatting.

Lists & tuples

Lists and tuples are Python's core ordered collections, one mutable and one not, and these posts cover slicing, joining, sorting, list comprehensions, the shared sequence API, and quirks like += with a tuple.

Dictionaries & sets

Dictionaries map keys to values and sets store unique unordered items, both relying on hashing; these posts cover subset checks, dict.fromkeys pitfalls, memory usage, hashability, sorting lists of dicts, and building dicts with reduce.

Comprehensions

Comprehensions build lists, dicts, and sets from an iterable in a single expression; these posts explain nested comprehensions, rebuilding zip with them, and analogies to Excel and SQL thinking.

Iterators & generators

Objects that produce values one at a time, on demand, rather than all at once; these posts show how to implement the iterator protocol yourself and how generators, coroutines, and "yield from" fit together.

Decorators

A decorator wraps a function to add behavior without changing its code; these posts demystify how they work, show why functools.wraps matters, and share slides and code from a conference talk.

Map, filter & reduce

Python's functional trio transforms, selects, and combines elements of a sequence; these posts work through map's mindset and a long series on reduce, using it to build dictionaries, min and max, filter, and Scrabble scores.

Scoping & namespaces

Python decides which variable or attribute a name refers to using rules like LEGB and ICPO; these posts walk through those lookup paths, keyword-argument confusion, and odd cases like True+True.

Modules & imports

Python code is organized into modules that you load with import; these posts trace how a module name is resolved to a file on sys.path, how to reload a module while developing, and how the subprocess module handles shell globbing.

Exceptions & error handling

Python signals problems by raising exceptions, and these posts cover raising and catching them, working with warnings, and reading a traceback.

More topics

AI-assisted coding

Using LLMs and agents as part of everyday Python work, with posts on learning to code alongside AI, agentic coding workflows, and how developer skills are shifting.

course-setup

A tool for getting students' Python environments ready before training begins; this post introduces course-setup and explains how instructors can use it in their own classes.

Dates & times

Working with dates and times in Python means using the datetime module's objects and methods, and here you'll see how weekday() identifies Saturdays and Sundays.

Files & I/O

Reading and writing files means dealing with paths, handles, and cleanup, and these posts cover how imports resolve module names to files, deleting files based on other filenames, and when Python actually closes a file without "with".

Git

Git is the version-control system most developers use daily, and these posts cover practical shortcuts like jumping back to your last branch, plus courses and in-browser exercises for practicing it.

Identity & equality

Python's `is` operator checks whether two names point to the same object, while `==` compares values; these posts explain the difference and why `is` is rarely what you want.

Loops & control flow

Loops and conditionals decide how many times your code runs and in what order; here you'll find a look at Python's lesser-known else clause on for and while loops.

Numbers & precision

Python's numeric types behave in surprising ways, and these posts explain banker's rounding, floating-point quirks, underscores in numeric literals, bitwise operators, and why booleans can be added like integers.

Regular expressions

Regular expressions are compact patterns for matching text, and these posts offer encouragement and practical guidance for learning them, plus how to apply them inside PostgreSQL queries.

Shell & developer tools

The Unix command line is where most Python work happens, and these posts cover two everyday tools: the find utility for locating files, and Control-R for searching your shell history.

Syntax & formatting

Python's punctuation and line structure shape how readable your code is; these posts cover what parentheses do, how to split long lines across multiple lines, and when clever syntax goes too far.

Teaching Python

Helping others learn Python brings its own challenges, and this post introduces course-setup, a tool for getting students' environments ready before training begins.

uv & packaging

uv is a fast Python package and project manager that replaces pip and virtualenv; these posts show how to start with it and avoid common mistakes in how people use it.

Variables & assignment

Variables in Python are names bound to objects rather than boxes holding values, and these posts cover how assignment works, the several ways to assign names, and why comparison and assignment differ.

Browse all Python courses →