On this page
Scopes that nest๏
Beginner. Child scopes, no configuration.
import melder as md
class Config:
"""Shared configuration for this example."""
class Session:
"""State scoped to one conduit."""
book = md.Spellbook()
book.bind(spell=Config, existence="unique")
book.bind(spell=Session, existence="unique_per_conduit")
with book.conjure() as root:
with root.enter_lesser_conduit() as child:
assert root.meld("Config") is child.meld("Config") # shared
assert root.meld("Session") is not child.meld("Session") # per-scope
Expected outcome: both assertions pass, with no printed output. The child scope ends first, then the root; a child does not create another book or another root.
Runnable examples๏
Lesser conduit scopes โ Beginner 05
Pass the conduit around โ Beginner 27
Scope contrast one tree โ Beginner 34