Finite state machine in python

Tim Chase python.list at
Sun Sep 13 03:55:13 CEST 2009

> I have see some discussion on the implementation of finite
> state machine in python. Can somebody point to me the best way
> in implenting an FSM in python?

To offer a "best way" requires knowing more about what you're 
trying to accomplish.  Are you looking for just some fixed 
states?  are you looking to dynamically adjust the available 
states?  Is this workflow for a single user, or is it for 
multiple users?  A FSM merely involves a list of states and the 
transitions between them.  You can augment the states and/or the 
transitions with additional metadata.  You can store your states 
in fixed internal hard-coded structures, or you can store them in 
a file/database that can grow external.

I posted information on doing this with a SQL-ish database 
(whether sqlite or whatever) a while back, so you can see a more 
"complex" version of tracking this info:

Hope this gives you some ideas from which to choose an option 
that's "best" for your needs.


More information about the Python-list mailing list