'Switch to the desired mode.
If mode is not specified, cycles through the available modes.'

def set_mode(self, mode=None):

    if (not mode):
        new_idx = ((self.valid_modes.index(self.mode) + 1) % len(self.valid_modes))
        self.mode = self.valid_modes[new_idx]
    elif (mode not in self.valid_modes):
        raise ValueError(((('Unrecognized    mode    in    FormattedTB:    <' + mode) + '>\nValid    modes:    ') + str(self.valid_modes)))
    else:
        self.mode = mode
    self.include_vars = (self.mode == self.valid_modes[2])
    self.tb_join_char = self._join_chars[self.mode]
