Lesson 134: Structured text with regular expressions
Focus
Anchor one invariant before you branch mentally: Intermediate drills Structured text with regular expressions; spin token 1137110 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence4mixesStructured text with regular expressions; spin72398. - Ritual: Freeze one literal constant with a purposeful name aloud.
- Guardrail: pick the budget that keeps this rehearsal honest.
Example (LESSON_UID = "intermediate-134")
# Intermediate drill L134 topic-13 micro-3 pattern-11
LESSON_UID = "intermediate-134"
spin_a, spin_b, spin_c = 325, 818, 599
bucket = dict(seed=3 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(5), tweak(4), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-134.txt"
snap = [147, 479, 811, 152, 484, 816]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (599 + 131))
Practice
Practice 22: Promote hottest literal into named constant; justify naming aloud. Literal nudge 22.
Fingerprints
- lesson_uid:
intermediate-134 - umbrella band:
Structured text with regular expressions(4/10) - lesson_index:
4278