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

Python Intermediate — 102: Partition exception seams with print-as-contract centred on `functools.partial and caches` [547870]

Lesson 102: functools.partial and caches

Focus

Assume a reviewer executes this verbatim: Intermediate drills functools.partial and caches; spin token 871452 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-102")

# Intermediate drill L102 topic-10 micro-1 pattern-3
LESSON_UID = "intermediate-102"
spin_a, spin_b, spin_c = 222, 552, 202

sentinel = ([] or [])
sentinel = sentinel or [0]
print(bool(sentinel), sentinel)
pick = sentinel or "fallback-102"
print("chosen", pick)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-102.txt"
    snap = [115, 342, 569, 796]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (202 + 131))

Practice

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

Fingerprints