code: def switch_to(self, newstate):
          
          if type(newstate) is int:
              if newstate in self._states:
                  self._curcode = newstate
              else:
                  raise Exception("The state value " + str(newstate) + " does not exist.")            
          else:
              if newstate in self._scodes:
                  self._curcode = self._scodes[newstate]
              else:
                  raise Exception("The state " + newstate + " does not exist.")
docs: Switch to a new state
          
          newstate : int or string
              Can be either the value of the state, or the label of the state