Python state-machine design

后端 未结 12 2168
予麋鹿
予麋鹿 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:27

    There is this design pattern for using decorators to implement state machines. From the description on the page:

    Decorators are used to specify which methods are the event handlers for the class.

    There is example code on the page as well (it is quite long so I won't paste it here).

提交回复
热议问题