case/switch statement?
Roy Smith
roy at panix.com
Thu Jun 23 08:42:47 EDT 2005
"NickC" <ncoghlan at gmail.com> wrote:
> The thing I love most about Python is the fact that callables can be
> slung around at run-time, just like any other object.
Yup. A while ago, I was doing a lot of file parsing with state machines.
Each state was a function. The main loop of the state machine was just:
state = start
while state != end:
state, output = state (input)
Each function was responsible for returning a (nextState, output) tuple.
More information about the Python-list
mailing list