Lesson 021: Custom iterators and iter() bridges
Focus
Treat the excerpt as executable notes: Intermediate drills Custom iterators and iter() bridges; spin token 173647 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence1mixesCustom iterators and iter() bridges; spin10825. - Ritual: Sketch control flow as ASCII before trusting output.
- Guardrail: promise one security boundary if this touched user data.
Example (LESSON_UID = "intermediate-021")
# Intermediate drill L021 topic-2 micro-0 pattern-10
LESSON_UID = "intermediate-021"
spin_a, spin_b, spin_c = 183, 653, 129
def gate(v):
if v < spin_a + 0:
return "low", v ** 2
if v > spin_b + 21:
return "high", v // max(1, 0 + 1)
return "mid", v + spin_c
cand = [0, 21, 163]
for candidate in cand:
lbl, val = gate(candidate)
print(candidate, lbl, val)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-21.txt"
snap = [34, 221, 408]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (129 + 131))
Practice
Practice 25: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 25.
Fingerprints
- lesson_uid:
intermediate-021 - umbrella band:
Custom iterators and iter() bridges(1/10) - lesson_index:
641