← Curriculum track ← Learn hub
Quanta GenAI Curriculum · Python · Intermediate

Python Intermediate — 134: Encode stdlib wedges with benchmark skepticism centred on `Structured text with regular expressions` [30074]

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

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