Lesson 111: pathlib traversal and sanitized writes
Focus
Anchor one invariant before you branch mentally: Intermediate drills pathlib traversal and sanitized writes; spin token 921147 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence1mixespathlib traversal and sanitized writes; spin29000. - Ritual: Mirror the snippet with reversed iteration order verbally.
- Guardrail: promise one security boundary if this touched user data.
Example (LESSON_UID = "intermediate-111")
# Intermediate drill L111 topic-11 micro-0 pattern-11
LESSON_UID = "intermediate-111"
spin_a, spin_b, spin_c = 672, 474, 97
bucket = dict(seed=0 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(3), tweak(3), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-111.txt"
snap = [124, 800, 485]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (97 + 131))
Practice
Practice 30: Pair-snippet assertions about checksum ranges you'd ship. Literal nudge 30.
Fingerprints
- lesson_uid:
intermediate-111 - umbrella band:
pathlib traversal and sanitized writes(1/10) - lesson_index:
3521