Logo Search packages:      
Sourcecode: rapid-spring version File versions  Download package

def rapid::main::TextUserInteraction::choose_many (   self,
  header,
  options,
  question 
)
Let the user choose multiple options from a list.

Definition at line 32 of file main.py.

                                                      :
            """ Let the user choose multiple options from a list."""
            print header
            for i in range(len(options)):
                  print '%2i.  %s' % (i + 1, options[i])
            which = raw_input(question + ' [enter number(s) or "all"]: ')
            if which.lower().strip() == 'all':
                  return options
            which = re.split(r'[\s,]+', which)
            try:
                  n = len(options)
                  which = [self._to_i_bounds_check(x, 1, n) - 1 for x in which]
            except (ValueError, IndexError) as e:
                  print type(e).__name__ + ':', str(e)
                  return []
            return [options[x] for x in which]


Generated by  Doxygen 1.6.0   Back to index