Domain tools
41 steps in 11 sets of Python.
The standard library doing real jobs. Regular expressions, sockets, HTTP both directions, sqlite3, and the formats you end up parsing whether you wanted to or not: JSON, CSV, and their awkward cousins.
Then the parts nobody teaches and everybody needs. argparse, pathlib and the archive modules, bytes and hashlib and secrets, configuration and the eternal misery of time zones, and finally the measuring tools, timeit and dis and inspect, for when you need to know what Python is actually doing.
Regular expressions
- Regex search & findallThe core re functions for finding text patterns.
- Named capture groupsLabeling the parts of a match for readable extraction.
- SubstitutionRewriting text with re.sub, including callbacks.
- Regex validationUsing fullmatch to check that a whole string fits.
- Regex flagsChanging how a pattern matches with re flags.
Sockets & networking
- A TCP clientOpening a socket and speaking raw HTTP to a server.
- A TCP serverBinding a socket and echoing back what clients send.
- UDP datagramsConnectionless messaging with SOCK_DGRAM sockets.
- DNS and address lookupResolving names, ports, and addresses with socket helpers.
Web
- urllib GET requestsFetching JSON from an API with the standard library.
- urllib POST requestsSending a JSON body with urllib, no third-party libs.
- A minimal HTTP serverServing one request with http.server's base handler.
- Parsing URLsTaking URLs apart and putting query strings together.
Databases
- SQLite basicsCreate, insert, and query with the built-in sqlite3.
- SQLite row accessReading query results by column name.
- SQLite transactionsGrouping writes so they all commit or all roll back.
Data formats
- JSON round-tripsSerializing to JSON text and parsing it back.
- CSV with dictionariesReading and writing CSV rows as dicts.
- The collections moduleCounter, defaultdict, and deque for everyday jobs.
- Dates and timesArithmetic and formatting with datetime and timedelta.
- Binary data with structPacking and unpacking C-style binary records.
Command line
- argparseA parser built from declarations gives you help, types and errors for free.
- SubcommandsSubparsers give one program several verbs, each with its own arguments.
- loggingA logger per module, a level, and a format: never print for diagnostics.
- subprocessrun a command, capture its output, and check the exit code.
Files & archives
- pathlib, furtherGlobbing, suffixes, reading and writing, all without touching os.path.
- Temporary files and treesScratch space that cleans itself up, and the tree operations worth knowing.
- Compression and archivesgzip for a stream, zipfile and tarfile for a bundle.
- Writing CSVDictWriter takes rows as dicts and writes the header for you.
Bytes & secrets
- Hashing and secretsDigests for integrity, hmac for authenticity, secrets for tokens.
- Encoding bytes as textbase64 when bytes must survive a text channel, hex when humans read it.
Configuration & time
- Reading TOML and INItomllib is in the standard library, read-only; configparser handles INI.
- Dates, times and zonesAware datetimes only: a naive one is a bug waiting for a deploy.
- The statistics moduleMean, median, spread and quantiles without reaching for numpy.
Measuring & introspecting
- Measuring codetimeit runs it enough times to mean something, in an isolated namespace.
- IntrospectionAsking an object about itself: signature, docstring, source, members.
- contextlib's other toolssuppress, redirect_stdout, ExitStack and closing.
- sqlite3, furtherRow factories, parameter binding and the transaction context manager.
Encore
- port_scanner.pyScan a host for open ports from a common list.
- log_report.pySummarize an access log's statuses, paths, and bytes.
- py_log_scanner.pyA log scanner with argparse, logging, regex and a summary table.