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

Python Intermediate — 106: Re-shape exception seams with tuple witnesses centred on `functools.partial and caches` [521474]

Lesson 106: functools.partial and caches

Focus

Let the literals expose mistaken assumptions quickly: Intermediate drills functools.partial and caches; spin token 876250 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-106")

# Intermediate drill L106 topic-10 micro-5 pattern-3
LESSON_UID = "intermediate-106"
spin_a, spin_b, spin_c = 558, 514, 348

sentinel = ([] or [])
sentinel = sentinel or [4]
print(bool(sentinel), sentinel)
pick = sentinel or "fallback-106"
print("chosen", pick)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-106.txt"
    snap = [119, 686, 262, 829]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (348 + 131))

Practice

Practice 42: Attach property-style expectations referencing tuple shapes. Literal nudge 42.

Fingerprints