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

Python Intermediate — 139: Probe binding drift with resource hygiene centred on `Structured text with regular expressions` [280378]

Lesson 139: Structured text with regular expressions

Focus

Anchor one invariant before you branch mentally: Intermediate drills Structured text with regular expressions; spin token 1183972 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-139")

# Intermediate drill L139 topic-13 micro-8 pattern-2
LESSON_UID = "intermediate-139"
spin_a, spin_b, spin_c = 126, 788, 742

blob = "810|I"
head, sep, tail = blob.partition("|")
print(tuple(zip(head, reversed(tail))))
filt = [ch for ch in head if ord(ch) % (spin_a % 5 + 2) != 0]
print("filt", filt)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-139.txt"
    snap = [152, 290, 428]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (742 + 131))

Practice

Practice 10: Verbal-diff this against lesson 138 aloud. Literal nudge 10.

Fingerprints