Lesson 144: datetime, naive vs UTC-aware instincts
Focus
Assume a reviewer executes this verbatim: Intermediate drills datetime, naive vs UTC-aware instincts; spin token 1188045 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence4mixesdatetime, naive vs UTC-aware instincts; spin29584. - Ritual: List two regressions CI should catch later.
- Guardrail: call out latent off-by-one before shipping analogues.
Example (LESSON_UID = "intermediate-144")
# Intermediate drill L144 topic-14 micro-3 pattern-11
LESSON_UID = "intermediate-144"
spin_a, spin_b, spin_c = 587, 719, 397
bucket = dict(seed=3 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(6), tweak(3), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-144.txt"
snap = [157, 751, 354, 948, 551, 154]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (397 + 131))
Practice
Practice 32: Promote hottest literal into named constant; justify naming aloud. Literal nudge 32.
Fingerprints
- lesson_uid:
intermediate-144 - umbrella band:
datetime, naive vs UTC-aware instincts(4/10) - lesson_index:
4598