Lesson 119: pathlib traversal and sanitized writes
Focus
Compare against yesterday's mental model politely: Intermediate drills pathlib traversal and sanitized writes; spin token 1026236 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence9mixespathlib traversal and sanitized writes; spin26164. - Ritual: Sketch control flow as ASCII before trusting output.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "intermediate-119")
# Intermediate drill L119 topic-11 micro-8 pattern-5
LESSON_UID = "intermediate-119"
spin_a, spin_b, spin_c = 973, 455, 731
hop = (spin_a % 13) + 8 + 11
total = (spin_b + 119 * spin_c) % 5003
while hop < (687 % 61) + 30:
total += hop
hop = hop * (741 % 5 + 1) % (spin_a % 127 + 8 + 17)
if total % (spin_b % 17 + 8 + 11) == 0:
break
print(total, hop)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-119.txt"
snap = [132, 126, 120]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (731 + 131))
Practice
Practice 42: Discuss packaging layout deltas if helpers became a module. Literal nudge 42.
Fingerprints
- lesson_uid:
intermediate-119 - umbrella band:
pathlib traversal and sanitized writes(9/10) - lesson_index:
3833