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. No mapping required. But if you want a dict in there somewhere, feel free to put one in :-) I was complaining about the function-call overhead of this method though, which can be quite significant for a FSM where each state does only a little processing, and there are many transitions - such as in a parser reading in a large file. The byte-code rewriting hack mentioned in a previous post eliminates this overhead. But, I concede, is somewhat ugly. Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list