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

Python Intermediate — 049: Nudge typing seams with scaffolding comments centred on `Exceptions: catching, chaining, guarding` [315588]

Lesson 049: Exceptions: catching, chaining, guarding

Focus

Assume a reviewer executes this verbatim: Intermediate drills Exceptions: catching, chaining, guarding; spin token 443443 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-049")

# Intermediate drill L049 topic-4 micro-8 pattern-12
LESSON_UID = "intermediate-049"
spin_a, spin_b, spin_c = 978, 974, 337

from io import StringIO

buf = StringIO()
rounds = 3 + 8 % 5
for idx in range(rounds):
    buf.write(f"seg-{idx}-{(idx * 49 + 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-49.txt"
    snap = [62, 61, 60]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (337 + 131))

Practice

Practice 9: Shadow one variable purposely to spotlight scope quirks. Literal nudge 9.

Fingerprints