def event(self, value):
        """ Trigger a transition - return a tuple (<new_state>, <changed>)
            Raise an exception if no valid transition exists.
            Callee needs to determine if the value should be consumed or re-used
        """
        if not self.currentState:
            raise ValueError("StateMachine not Started - cannot process event")

        # get a unique list of next states which are valid       
        self.nextState = list(set( \
                    [ x[1] for x in self._states\
                    if x[0] == self.currentState \
                            and (x[2]==True or (callable(x[2]) and x[2](value))) ] ) ) 

        if not self.nextState: 
            raise ValueError("No Transition defined from state {0} with value '{1}'".format(self.currentState, value))
        elif len(self.nextState) > 1:
            raise ValueError("Ambiguous transitions from state {0} with value '{1}' ->  New states defined {2}".format(self.currentState, value, self.nextState))
        else:
            self.currentState, ret = (self.nextState[0], True) \
                    if self.currentState != self.nextState[0] else (self.nextState[0], False)
            return self.currentState, ret
 Trigger a transition - return a tuple (<new_state>, <changed>)
            Raise an exception if no valid transition exists.
            Callee needs to determine if the value should be consumed or re-used
        
recipes/Python/578332_Simple_Finite_State_Machine/recipe-578332.py