Lesson 113: pathlib traversal and sanitized writes
Focus
Treat the excerpt as executable notes: Intermediate drills pathlib traversal and sanitized writes; spin token 960443 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence3mixespathlib traversal and sanitized writes; spin23147. - Ritual: Swap one benign literal twice to see binding effects.
- Guardrail: call out latent off-by-one before shipping analogues.
Example (LESSON_UID = "intermediate-113")
# Intermediate drill L113 topic-11 micro-2 pattern-7
LESSON_UID = "intermediate-113"
spin_a, spin_b, spin_c = 306, 996, 920
src = [((k + 113) * spin_a + 2) % 241 for k in range(4 + 2 % 3)]
derived = [v * v if v % 2 == 0 else v + spin_b for v in src]
print("src", src)
print("derived", derived)
print("zip_sum", sum(x + y for x, y in zip(src, derived)))
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-113.txt"
snap = [126, 438, 750, 71, 383]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (920 + 131))
Practice
Practice 37: Swap print order once; reconcile dependency thinking. Literal nudge 37.
Fingerprints
- lesson_uid:
intermediate-113 - umbrella band:
pathlib traversal and sanitized writes(3/10) - lesson_index:
3599