Lesson 028: Custom iterators and iter() bridges
Focus
Assume a reviewer executes this verbatim: Intermediate drills Custom iterators and iter() bridges; spin token 241787 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence8mixesCustom iterators and iter() bridges; spin23606. - Ritual: Freeze one literal constant with a purposeful name aloud.
- Guardrail: pick the budget that keeps this rehearsal honest.
Example (LESSON_UID = "intermediate-028")
# Intermediate drill L028 topic-2 micro-7 pattern-8
LESSON_UID = "intermediate-028"
spin_a, spin_b, spin_c = 881, 423, 222
pairs = [(5, 28), (7, 2), (28, 71)]
flat = 15
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-28.txt"
snap = [41, 933, 834, 735, 636, 537]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (222 + 131))
Practice
Practice 40: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 40.
Fingerprints
- lesson_uid:
intermediate-028 - umbrella band:
Custom iterators and iter() bridges(8/10) - lesson_index:
914