If action comes from outside the program, this can open up unexpected behavior. The dispatch table is closed - there's less chance that user input will invoke something unintended.
# {state_name: state_action}
states = {}
state = ['start']
def reg(func):
states[func.__name__] = func
return func
# define and simultaneously register the states
@reg
def start():
state[0] = 'second'
@reg
def second():
state[0] = 'last'
@reg
def last():
state[0] = None
# run the state machine
while state[0]:
print state[0]
states[state[0]]()