comparison cmd2.py @ 332:49bea7cab179

doc refreshing refresh.bash
author cat@eee
date Fri, 12 Feb 2010 22:15:04 -0500
parents 6306edc46a6e
children 45e70737791f
comparison
equal deleted inserted replaced
331:6306edc46a6e 332:49bea7cab179
939 def select(self, options, prompt='Your choice? '): 939 def select(self, options, prompt='Your choice? '):
940 '''Presents a numbered menu to the user. Modelled after 940 '''Presents a numbered menu to the user. Modelled after
941 the bash shell's SELECT. Returns the item chosen. 941 the bash shell's SELECT. Returns the item chosen.
942 942
943 Argument ``options`` can be: 943 Argument ``options`` can be:
944 a single string -> will be split into one-word options 944
945 a list of strings -> will be offered as options 945 | a single string -> will be split into one-word options
946 a list of tuples -> interpreted as (value, text), so 946 | a list of strings -> will be offered as options
947 that the return value can differ from 947 | a list of tuples -> interpreted as (value, text), so
948 the text advertised to the user ''' 948 that the return value can differ from
949 the text advertised to the user '''
949 if isinstance(options, basestring): 950 if isinstance(options, basestring):
950 options = zip(options.split(), options.split()) 951 options = zip(options.split(), options.split())
951 fulloptions = [] 952 fulloptions = []
952 for opt in options: 953 for opt in options:
953 if isinstance(opt, basestring): 954 if isinstance(opt, basestring):