def read_user_choice(var_name, options):
 if (not isinstance(options, list)):
  raise TypeError
 if (not options):
  raise ValueError
 choice_map = OrderedDict(((u'{}'.format(i), value) for (i, value) in enumerate(options, 1)))
 choices = choice_map.keys()
 default = u'1'
 choice_lines = [u'{} - {}'.format(*c) for c in choice_map.items()]
 prompt = u'\n'.join((u'Select {}:'.format(var_name), u'\n'.join(choice_lines), u'Choose from {}'.format(u', '.join(choices))))
 user_choice = click.prompt(prompt, type=click.Choice(choices), default=default)
 return choice_map[user_choice]

def read_user_choice ( var_name , options ) : if ( not isinstance ( options , list ) ) : raise TypeError if ( not options ) : raise ValueError choice_map = OrderedDict ( ( ( u'{}' . format ( i ) , value ) for ( i , value ) in enumerate ( options , 1 ) ) ) choices = choice_map . keys ( ) default = u'1' choice_lines = [ u'{} - {}' . format ( * c ) for c in choice_map . items ( ) ] prompt = u'\n' . join ( ( u'Select {}:' . format ( var_name ) , u'\n' . join ( choice_lines ) , u'Choose from {}' . format ( u', ' . join ( choices ) ) ) ) user_choice = click . prompt ( prompt , type = click . Choice ( choices ) , default = default ) return choice_map [ user_choice ]
prompt the user to choose from several options for the given variable .