code: def cmd_mode(self, args):
          '''set arbitrary mode'''
          mode_mapping = self.master.mode_mapping()
          if mode_mapping is None:
              print('No mode mapping available')
              return
          if len(args) != 1:
              print('Available modes: ', mode_mapping.keys())
              return
          if args[0].isdigit():
              modenum = int(args[0])
          else:
              mode = args[0].upper()
              if mode not in mode_mapping:
                  print('Unknown mode %s: ' % mode)
                  return
              modenum = mode_mapping[mode]
          self.master.set_mode(modenumf cmd_mode(self, args):
          '''set arbitrary mode'''
          mode_mapping = self.master.mode_mapping()
          if mode_mapping is None:
              print('No mode mapping available')
              return
          if len(args) != 1:
              print('Available modes: ', mode_mapping.keys())
              return
          if args[0].isdigit():
              modenum = int(args[0])
          else:
              mode = args[0].upper()
              if mode not in mode_mapping:
                  print('Unknown mode %s: ' % mode)
                  return
              modenum = mode_mapping[mode]
          self.master.set_mode(modenum)
docs: set arbitrary mode