On this page

Frames as dict classification๏ƒ

๐ŸŸข Beginner ยท Lesson 25

Spellframes are CATEGORIES. Organize one world's spells by the resolution ideas your app already has - "repositories", "notifiers" - and (category, name) becomes the full address. A frame IS an interface dict keyed by binding_name: a member is looked up through its frame - [category][name] - and never by its own class alone (a class lookup reaches only a spell bound bare; owner ruling 2026-11-07). A string frame groups; a Protocol frame also VALIDATES what binds under it (intermediate tier). Seed for later: when a category needs its own OWNER and its own resolution conditions, the category graduates into a whole CONDUIT - that story is intermediate lesson 26.

Before you run๏ƒ

Use the Beginner 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/01_beginner/25_frames_as_dict_classification.py
py -3.14t UX_and_AIX_experiences/01_beginner/25_frames_as_dict_classification.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

spellframe + binding_name as a category address space

Code๏ƒ

 1"""
 2TIER: beginner (25)
 3GOAL: Spellframes are CATEGORIES. Organize one world's spells by the
 4      resolution ideas your app already has - "repositories",
 5      "notifiers" - and (category, name) becomes the full address.
 6      A frame IS an interface dict keyed by binding_name: a member is
 7      looked up through its frame - [category][name] - and never by
 8      its own class alone (a class lookup reaches only a spell bound
 9      bare; owner ruling 2026-11-07). A string frame groups; a
10      Protocol frame also VALIDATES what binds under it
11      (intermediate tier).
12      Seed for later: when a category needs its own OWNER and its own
13      resolution conditions, the category graduates into a whole
14      CONDUIT - that story is intermediate lesson 26.
15SURFACE EXERCISED: spellframe + binding_name as a category address space
16"""
17import melder as md
18
19
20class UsersRepo:
21    pass
22
23
24class OrdersRepo:
25    pass
26
27
28class SlackNotifier:
29    pass
30
31
32class EmailNotifier:
33    pass
34
35
36WORLD = {
37    "repositories": {"users": UsersRepo, "orders": OrdersRepo},
38    "notifiers": {"slack": SlackNotifier, "email": EmailNotifier},
39}
40
41
42def main() -> None:
43    book = md.Spellbook()
44    for frame, members in WORLD.items():
45        for name, cls in members.items():
46            book.bind(spell=cls, existence="unique",
47                      spellframe=frame, binding_name=name)
48    conduit = book.conjure()
49
50    # melding = looking up a category member by its full address
51    users = conduit.meld("UsersRepo", spellframe="repositories",
52                         binding_name="users")
53    email = conduit.meld("EmailNotifier", spellframe="notifiers",
54                         binding_name="email")
55    assert isinstance(users, UsersRepo) and isinstance(email, EmailNotifier)
56    print("categories addressed as [category][name]: repositories, notifiers")
57
58
59if __name__ == "__main__":
60    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.

More beginner examples ยท Level guide