Really nice Finite State machine in c and python