Lesson 109: Property-based assertions (Hypothesis)
Focus
This page is deliberate repetition with new literals: Advanced drills Property-based assertions (Hypothesis); spin token 903447 makes this page unlike its neighbours.
Key ideas
- Angle
Advanced: micro cadence9mixesProperty-based assertions (Hypothesis); spin22680. - Ritual: Swap one benign literal twice to see binding effects.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "advanced-109")
# Advanced drill L109 topic-10 micro-8 pattern-2
LESSON_UID = "advanced-109"
spin_a, spin_b, spin_c = 354, 291, 247
blob = "93|I"
head, sep, tail = blob.partition("|")
print(tuple(zip(head, reversed(tail))))
filt = [ch for ch in head if ord(ch) % (spin_a % 5 + 2) != 0]
print("filt", filt)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-109.txt"
snap = [122, 488, 854]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (247 + 131))
import asyncio
async def finalize(seed, spin):
await asyncio.sleep(0)
blend = (seed * 131 + 10 * (10 % 997) + 8 * (8 % 853) + spin) % 900001
return blend
async def harness(loop_seed):
print("async_result", await finalize(loop_seed, 66100))
asyncio.run(harness(87137))
Practice
Practice 40: Rename locals for domain vocabulary-only; keep behaviour identical. Literal nudge 40.
Fingerprints
- lesson_uid:
advanced-109 - umbrella band:
Property-based assertions (Hypothesis)(9/10) - lesson_index:
3513