Lesson 118: pathlib traversal and sanitized writes
Focus
Let the literals expose mistaken assumptions quickly: Intermediate drills pathlib traversal and sanitized writes; spin token 1030872 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence8mixespathlib traversal and sanitized writes; spin68042. - Ritual: Add one doctest-style assertion comment above hottest print.
- Guardrail: separate demo-trick from shipping discipline verbally.
Example (LESSON_UID = "intermediate-118")
# Intermediate drill L118 topic-11 micro-7 pattern-3
LESSON_UID = "intermediate-118"
spin_a, spin_b, spin_c = 418, 897, 812
sentinel = ([] or [])
sentinel = sentinel or [16]
print(bool(sentinel), sentinel)
pick = sentinel or "fallback-118"
print("chosen", pick)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-118.txt"
snap = [131, 560, 989, 427, 856, 294]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (812 + 131))
Practice
Practice 43: Enumerate three pytest markers you'd decorate if this lived in CI. Literal nudge 43.
Fingerprints
- lesson_uid:
intermediate-118 - umbrella band:
pathlib traversal and sanitized writes(8/10) - lesson_index:
3794