Python state-machine design

后端 未结 12 2139
予麋鹿
予麋鹿 2020-11-30 17:36

Related to this Stack Overflow question (C state-machine design), could you Stack Overflow folks share your Python state-machine design techniques

12条回答
  •  生来不讨喜
    2020-11-30 18:11

    It probably depends on how complex your state machine is. For simple state machines, a dict of dicts (of event-keys to state-keys for DFAs, or event-keys to lists/sets/tuples of state-keys for NFAs) will probably be the simplest thing to write and understand.

    For more complex state machines, I've heard good things about SMC, which can compile declarative state machine descriptions to code in a wide variety of languages, including Python.

提交回复
热议问题