LearnMusi for DevelopersMusi for Python DevelopersRecords, Objects, and Dictionaries

Records, Objects, and Dictionaries

Read Records, Objects, and Dictionaries as a Python habit shift, with links to the Musi Book definition.

Python dicts and objects make it easy to grow shape as code runs. Musi examples write the shape before using it, so a pet, receipt, or route has fields readers can trust.

python
from dataclasses import dataclass

@dataclass
class Pet:
    name: str
    age: int

dog = Pet("Miso", 4)

Reading Records, Objects, and Dictionaries from Python

On the Musi side, Musi records and data variants describe stored shape. Behavior belongs in functions or classes/instances, not inside an object by default. Read the shared example through Python eyes: keep the useful instinct, then let Musi name shape, behavior, absence, and outside work in separate places.

False friend

Do not read class as object shape. If the page is about a pet, invoice, room, or vehicle, start with fields or variants. For a Python reader, the trap is trusting runtime convention where Musi expects a visible type or effect; Musi class is closer to an explicit protocol/typeclass than a Python class with attributes and methods.

When this pays off

Use records when names like owner, age, amount, or route are the point of the value. The Python instinct still helps here: Keep the Python habit of naming the real-world thing first.

Keep close