On this page

Lesser conduit scopes๏ƒ

๐ŸŸข Beginner ยท Lesson 05

Scopes without ceremony - a lesser conduit is a child resolution scope; unique_per_conduit gives each scope its own instance while plain unique stays shared across the family.

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

Download this collection ยท Source on GitHub

Public surface๏ƒ

md.Spellbook, md.Existence.unique_per_conduit, md.Conduit.create_lesser_conduit

Code๏ƒ

 1"""
 2TIER: beginner (05)
 3GOAL: Scopes without ceremony - a lesser conduit is a child resolution
 4      scope; unique_per_conduit gives each scope its own instance while
 5      plain unique stays shared across the family.
 6SURFACE EXERCISED: md.Spellbook, md.Existence.unique_per_conduit,
 7                   md.Conduit.create_lesser_conduit
 8"""
 9import melder as md
10
11
12class AppWideConfig:
13    pass
14
15
16class PerScopeSession:
17    pass
18
19
20def main() -> None:
21    book = md.Spellbook()
22    book.bind(spell=AppWideConfig, existence="unique")
23    book.bind(spell=PerScopeSession, existence="unique_per_conduit")
24    root = book.conjure()
25    child = root.create_lesser_conduit()
26
27    assert root.meld("AppWideConfig") is child.meld("AppWideConfig")
28    print("unique: shared across root and child")
29
30    root_session = root.meld("PerScopeSession")
31    child_session = child.meld("PerScopeSession")
32    assert root_session is not child_session
33    assert child.meld("PerScopeSession") is child_session
34    print("unique_per_conduit: one per scope, stable within it")
35
36
37if __name__ == "__main__":
38    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

API contracts๏ƒ