On this page
Introspect the book๏
๐ก Intermediate ยท Lesson 14
The book is inspectable - the spells mapping hands back every registration as SpellIndex -> Spell, the system's two domain nouns, straight off the root namespace.
Before you run๏
Use the Intermediate guide for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules.
Run the saved script๏
python UX_and_AIX_experiences/02_intermediate/14_introspect_the_book.py
py -3.14t UX_and_AIX_experiences/02_intermediate/14_introspect_the_book.py
Public surface๏
md.Spellbook.spells, md.SpellIndex, md.Spell
Code๏
1"""
2TIER: intermediate (14)
3GOAL: The book is inspectable - the spells mapping hands back every
4 registration as SpellIndex -> Spell, the system's two domain
5 nouns, straight off the root namespace.
6SURFACE EXERCISED: md.Spellbook.spells, md.SpellIndex, md.Spell
7"""
8import melder as md
9
10
11class Alpha:
12 pass
13
14
15class Beta:
16 pass
17
18
19def main() -> None:
20 book = md.Spellbook()
21 book.bind(spell=Alpha, existence="unique")
22 book.bind(spell=Beta, existence="many")
23
24 registry = book.spells
25 assert len(registry) >= 2
26 for index, spell in registry.items():
27 assert isinstance(index, md.SpellIndex)
28 assert isinstance(spell, md.Spell)
29 print("book holds", len(registry), "spells, typed as SpellIndex -> Spell")
30
31
32if __name__ == "__main__":
33 main()
Check the outcome๏
The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here.