On this page

Hello, Melder๏ƒ

Beginner. A complete first program, including cleanup.

Prerequisites: install Melder, save this as hello.py, then run python hello.py.

import melder as md


class Greeter:
    """A plain class โ€” no base class, no metaclass, no decorator."""

    def greet(self) -> str:
        return "hello from a melded instance"


book = md.Spellbook()
book.bind(spell=Greeter, existence="unique")

with book.conjure() as conduit:
    greeter: Greeter = conduit.meld("Greeter")
    print(greeter.greet())
    assert conduit.meld("Greeter") is greeter   # `unique` โ†’ same instance
# Leaving the block cleans the root conduit and its owned Spellbook.

Expected output: hello from a melded instance. The assertion checks reuse; the block exit ends the scope. Your classes stay plain Python. Everything lives on md.* โ€” a deep import path is not needed for this workflow.

Pass the Python class or callable to bind; resolve it by its quoted registered name with meld("Greeter"). The tutorials use this name-based lookup throughout. Keep opaque machine identities explicit with meld(spell_id=...).


Runnable examples๏ƒ

All beginner examples ยท Level contents ยท Full contents

Canonical page source