On Sat, 04 Sep 2010 13:58:00 -0400 Roy Smith <r...@panix.com> wrote: > > while True: > > state = state(data) > > This is the pattern I've always used. Simple and effective for any > state machine which is small enough to code by hand. I generally have > my state methods return (next_state, output) tuples, but that's a detail.
What is "output" for? Is it a string or something else? What do you do with it? Notice that I create a dictionary which is passed around so that states can pass whatever information back that they deem useful and any state can pick up whatever info it needs. for example, in my sample code every state uses the counter but only two states use the flag element. -- D'Arcy J.M. Cain <da...@druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list