Python State Machine Classification