Lesson 117: pathlib traversal and sanitized writes
Focus
Let the literals expose mistaken assumptions quickly: Intermediate drills pathlib traversal and sanitized writes; spin token 999820 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence7mixespathlib traversal and sanitized writes; spin47106. - Ritual: Sketch control flow as ASCII before trusting output.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "intermediate-117")
# Intermediate drill L117 topic-11 micro-6 pattern-8
LESSON_UID = "intermediate-117"
spin_a, spin_b, spin_c = 207, 78, 164
pairs = [(61, 78), (6, 11), (4, 13)]
flat = 13
for left, right in sorted(pairs):
print(left ^ right + flat % 997)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-117.txt"
snap = [130, 347, 564, 781, 7]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (164 + 131))
Practice
Practice 33: Rename locals for domain vocabulary-only; keep behaviour identical. Literal nudge 33.
Fingerprints
- lesson_uid:
intermediate-117 - umbrella band:
pathlib traversal and sanitized writes(7/10) - lesson_index:
3755