Finite State Machines in Python