{"repo":"fgmacedo/python-statemachine","free":true,"listed":false,"github":"https://github.com/fgmacedo/python-statemachine","clone":"git clone https://github.com/fgmacedo/python-statemachine.git","description":"Expressive statecharts and FSMs for modern Python.","language":"Python","stars":1289,"topics":["state-machine","statemachine","automata","finite-state-machine","python","fsm","fsm-library","state","state-machine-diagram","state-machine-dsl"],"license":"MIT","category":"dev-tools","readme_excerpt":"Python StateMachine Expressive statecharts and FSMs for modern Python. Welcome to python-statemachine, an intuitive and powerful state machine library designed for a great developer experience. Define flat state machines or full statecharts with compound states, parallel regions, and history — all with a clean, pythonic , declarative API that works in both sync and async Python codebases. Quick start Create an instance and send events: Check which states are active: Generate a diagram or get a text representation with f-strings: Parameters are injected into callbacks automatically — the library inspects the signature and provides only the arguments each callback needs: Guards and conditional transitions Use cond= and unless= to add guards. When multiple transitions share the same event, declaration order determines priority: The first transition whose guard passes wins. When score < 70 , is valid returns False so the second transition (no guard — always matches) fires instead. Compound states — hierarchy Break complex behavior into hierarchical levels with State.Compound . Entering a compound activates both the parent and its initial child. Exiting removes the parent and all descendants: Parallel states — concurrency State.Parallel activates all child regions simultaneously. Events in one region don't affect others. A done.state event fires only when all regions reach a final state: History states HistoryState() records which child was active when a compound is exited. Re-ent","default_branch":null,"files":null,"tree":[],"storefront":"/r/fgmacedo","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/fgmacedo/python-statemachine/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}