python fsm