def option_chooser(options, attr=None):
 for (num, option) in enumerate(options):
  if attr:
   print(('%s: %s' % (num, getattr(option, attr))))
  else:
   print(('%s: %s' % (num, option)))
 escape_opt = (num + 1)
 print(('%s: I want to exit!' % escape_opt))
 choice = six.moves.input('Selection: ')
 try:
  ichoice = int(choice)
  if (ichoice > escape_opt):
   raise ValueError
 except ValueError:
  print(("Valid entries are the numbers 0-%s. Received '%s'." % (escape_opt, choice)))
  sys.exit()
 if (ichoice == escape_opt):
  print('Bye!')
  sys.exit()
 return ichoice

def option_chooser ( options , attr = None ) : for ( num , option ) in enumerate ( options ) : if attr : print ( ( '%s: %s' % ( num , getattr ( option , attr ) ) ) ) else : print ( ( '%s: %s' % ( num , option ) ) ) escape_opt = ( num + 1 ) print ( ( '%s: I want to exit!' % escape_opt ) ) choice = six . moves . input ( 'Selection: ' ) try : ichoice = int ( choice ) if ( ichoice > escape_opt ) : raise ValueError except ValueError : print ( ( "Valid entries are the numbers 0-%s. Received '%s'." % ( escape_opt , choice ) ) ) sys . exit ( ) if ( ichoice == escape_opt ) : print ( 'Bye!' ) sys . exit ( ) return ichoice
given an iterable .