Carl Cerecke wrote: > Chris Mellon wrote: > >> I'm not sure why nobody else in this thread said it, but the most >> common way of implementing state machines I've seen in Python (unless >> theres only a couple states you can manage with if/elif) is to use a >> dict to map states to callables. > > > Ah. Well, my post suggested, as one option, the callables call > each other directly.
Doh! No I didn't. And they shouldn't. Otherwise the call stack gets out of hand. But I did suggest that each callable representing a state set a global variable, just before it returns, to the callable representing the next state to be called. Still no map required. Just a while loop. In any case, the function call/return is wasted cycles. Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list