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

Python Intermediate — 059: Budget subprocess cages with defensive defaults centred on `Classes encapsulating mutable state` [19220]

Lesson 059: Classes encapsulating mutable state

Focus

Treat the excerpt as executable notes: Intermediate drills Classes encapsulating mutable state; spin token 510090 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-059")

# Intermediate drill L059 topic-5 micro-8 pattern-8
LESSON_UID = "intermediate-059"
spin_a, spin_b, spin_c = 831, 223, 741

pairs = [(28, 65), (8, 5), (59, 137)]
flat = 17
for left, right in sorted(pairs):
    print(left ^ right + flat % 997)

from pathlib import Path
import tempfile

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

Practice

Practice 44: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 44.

Fingerprints