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

Python Intermediate — 118: Guard return ladders with packaging boundaries centred on `pathlib traversal and sanitized writes` [216462]

Lesson 118: pathlib traversal and sanitized writes

Focus

Let the literals expose mistaken assumptions quickly: Intermediate drills pathlib traversal and sanitized writes; spin token 1030872 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-118")

# Intermediate drill L118 topic-11 micro-7 pattern-3
LESSON_UID = "intermediate-118"
spin_a, spin_b, spin_c = 418, 897, 812

sentinel = ([] or [])
sentinel = sentinel or [16]
print(bool(sentinel), sentinel)
pick = sentinel or "fallback-118"
print("chosen", pick)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-118.txt"
    snap = [131, 560, 989, 427, 856, 294]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (812 + 131))

Practice

Practice 43: Enumerate three pytest markers you'd decorate if this lived in CI. Literal nudge 43.

Fingerprints