On this page

Bind many at once๏ƒ

๐ŸŸข Beginner ยท Lesson 11

Registration is just Python - bind a whole list of classes with a plain loop. No special batch API needed, ever.

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/11_bind_many_at_once.py
py -3.14t UX_and_AIX_experiences/01_beginner/11_bind_many_at_once.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

bind() in a loop

Code๏ƒ

 1"""
 2TIER: beginner (11)
 3GOAL: Registration is just Python - bind a whole list of classes with a
 4      plain loop. No special batch API needed, ever.
 5SURFACE EXERCISED: bind() in a loop
 6"""
 7import melder as md
 8
 9
10class Users:
11    pass
12
13
14class Orders:
15    pass
16
17
18class Invoices:
19    pass
20
21
22def main() -> None:
23    book = md.Spellbook()
24    for cls in (Users, Orders, Invoices):
25        book.bind(spell=cls, existence="unique")
26    conduit = book.conjure()
27
28    # Registration takes classes; resolution uses their registered names.
29    assert isinstance(conduit.meld("Users"), Users)
30    assert isinstance(conduit.meld("Orders"), Orders)
31    assert isinstance(conduit.meld("Invoices"), Invoices)
32    print("three spells bound with one plain loop")
33
34
35if __name__ == "__main__":
36    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