Python programs operate on objects with explicit input, ownership and failure contracts.
Learning roadmap
This section contains 27 written lessons or quiz banks. Programs are verified on CPython 3.14.6. Standard-library lessons target 3.11+ syntax; lessons using data, web, machine-learning or testing packages state their tested dependencies separately. Framework programs use local test clients, not a deployed service. Read the stated limits before adapting a fixture into an application.
Text and file boundaries
Read the contract, run its program and inspect the failure case.
- Python JSON validation: reject duplicate members and non-integer amounts
- Python CSV imports: parse quoted fields before validating rows
- Python pathlib files: specify encoding and close the resource owner
Database and diagnostic boundaries
Read the contract, run its program and inspect the failure case.
- Python sqlite3 transactions: bind values and roll back failed batches
- Python logging: include bounded context without printing sensitive payloads
Field and test boundaries
Read the contract, run its program and inspect the failure case.
- Python regular expressions: use fullmatch for a complete field contract
- Python datetime: require an offset before comparing timestamps
- Python unittest: test rejected input and preserve state after failure
Bounded ingestion
Read the contract, run its program and inspect the failure case.
Configuration and disclosure boundaries
Read the contract, run its program and inspect the failure case.
- Python tomllib: parse configuration and validate its schema
- Python configuration precedence: merge, validate, then publish
- Python logging: allowlist fields before they reach a handler
Reception, writer contention and owned archive members
Read the contract, run its program and inspect the failure case.
- Python JSON Lines: cap line bytes and validate the whole batch before returning it
- Python SQLite writer contention: reject a busy transaction before changing state
- Python ZIP extraction: validate names and decompressed budgets before owned writes
Wire spelling, authentication and expansion budgets
Read the contract, run its program and inspect the failure case.
- Python strict Base64: reject alternate spellings before decoding a record
- Python HMAC envelopes: authenticate exact bytes and separate replay policy
- Python bounded gzip decoding: cap expanded output before publishing it
Partial input and nested rollback
Read the contract, run its program and inspect the failure case.
- Python SQLite savepoints: discard one substep without committing the batch
- Python SpooledTemporaryFile: rollover is a storage choice, not an upload limit
- Python socket recv: assemble a bounded frame across partial reads
Sorted feeds and relational integrity
Read the contract, run its program and inspect the failure case.
- Python heapq.merge: combine sorted feeds without sorting every value again
- Python SQLite foreign keys: enable enforcement on each connection
Ambiguous input fields
Read the contract, run its program and inspect the failure case.
- Python JSON duplicate keys: reject ambiguous object fields
- Python CSV headers: reject duplicate names before row mapping
SQLite key and replay rules
Read the contract, run its program and inspect the failure case.
- Python SQLite UNIQUE with NULL: an absent key can repeat
- Python SQLite upsert: make a replay update explicit
Continue learning
Move between tutorial, collections, advanced material and practice using the subject tabs. The sidebar changes with each section; related examples keep one canonical lesson URL.
