Skip to content

Stdlib practice problems in Python

Difficulty:
Category:
Tag:

Showing 37 of 37

Status Title Difficulty
accumulate and pairwise: max drawdown in one pass Easy
aclosing: release the connection on break, error and cancellation Hard
batched: page a stream, and validate before you yield Easy
cached_property: compute once, release with the instance, invalidate on demand Medium
cache: memoised edit distance behind a validated wrapper Medium
ChainMap: resolve config and keep the provenance Medium
contextmanager: temporarily patch an attribute, and put it back Medium
Counter: top n-grams with deterministic ties Easy
Dataclasses: slots, frozen, order Easy
@dataclass is a code generator: what it emits Easy
datetime: reject naive input, and find the next local wall clock Hard
defaultdict: group rows, hand back a plain dict Easy
deque: rolling median and the maxlen narrowing Medium
ExitStack: all-or-nothing acquisition of N resources Hard
field(): the seven knobs that change generated behaviour Medium
Flag: a permission mask that prints, iterates and refuses bad bits Medium
groupby: summarise rows without losing half of them Medium
heapq: a priority queue that is FIFO among equal priorities Medium
itertools: take n across chunks without over-consuming Easy
Lazy record batches: what laziness moves Medium
Logging in libraries: the hierarchy, the effective level, and whose configuration it is Medium
lru_cache on a method: fix the unbounded instance leak Hard
NamedTuple: when a record should be a tuple Medium
nullcontext and suppress: use the stream you were given, close only what you opened Easy
partial: a signature-preserving retrier, and the 3.14 descriptor change Medium
pathlib: safe_join, or how to not serve /etc/passwd Easy
Self-documenting f-strings: f"{x=}" Easy
singledispatch: a JSON encoder callers can extend from outside Hard
StrEnum: migrate a module of string constants without breaking callers Medium
Structured logging: events, not sentences Hard
The f-string format specification mini-language Easy
The mutable-default trap — and why the guard is weaker than you think Easy
tomllib: turn dict[str, Any] into a typed config, or a named error Medium
total_ordering: SemVer, where pre-release sorts before release Medium
walk: prune the subtree, not just the results Medium
What Actually Crosses a Process Boundary Medium
What goes on sys.path first Medium