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

Python Intermediate — 043: Encode async relays with packaging boundaries centred on `Exceptions: catching, chaining, guarding` [56172]

Lesson 043: Exceptions: catching, chaining, guarding

Focus

Compare against yesterday's mental model politely: Intermediate drills Exceptions: catching, chaining, guarding; spin token 353783 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-043")

# Intermediate drill L043 topic-4 micro-2 pattern-2
LESSON_UID = "intermediate-043"
spin_a, spin_b, spin_c = 380, 952, 245

blob = "172|C"
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-43.txt"
    snap = [56, 442, 828, 223, 609]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (245 + 131))

Practice

Practice 17: Promote hottest literal into named constant; justify naming aloud. Literal nudge 17.

Fingerprints