case/switch statement?

Roy Smith roy at
Thu Jun 23 14:42:47 CEST 2005

"NickC" <ncoghlan at> 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