Lesson 131: Structured text with regular expressions
Focus
Let the literals expose mistaken assumptions quickly: Intermediate drills Structured text with regular expressions; spin token 1091901 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence1mixesStructured text with regular expressions; spin72923. - Ritual: Swap one benign literal twice to see binding effects.
- Guardrail: separate demo-trick from shipping discipline verbally.
Example (LESSON_UID = "intermediate-131")
# Intermediate drill L131 topic-13 micro-0 pattern-12
LESSON_UID = "intermediate-131"
spin_a, spin_b, spin_c = 418, 741, 842
from io import StringIO
buf = StringIO()
rounds = 3 + 0 % 5
for idx in range(rounds):
buf.write(f"seg-{idx}-{(idx * 131 + spin_b) % 997}\n")
buf.seek(0)
dump = buf.read()
print("lines", dump.count("\n"))
print("peek", dump.splitlines()[0] if dump else "<empty>")
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-131.txt"
snap = [144, 566, 988]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (842 + 131))
Practice
Practice 9: Attach property-style expectations referencing tuple shapes. Literal nudge 9.
Fingerprints
- lesson_uid:
intermediate-131 - umbrella band:
Structured text with regular expressions(1/10) - lesson_index:
4161