#NEWLINE# def choose_multiple( somelist , chosen = None , prompt = 'choose multiple' , input = raw_input , error = default_error ) : #NEWLINE# #INDENT# somelist = somelist [ : ] #NEWLINE# if ( chosen is None ) : #NEWLINE# #INDENT# chosen = [ ] #NEWLINE# #UNINDENT# while 1 : #NEWLINE# #INDENT# print ( 'Choose from list. Enter to end, negative index removes from chosen.' ) #NEWLINE# print_menu_list ( somelist ) #NEWLINE# if chosen : #NEWLINE# #INDENT# print ( 'You have: ' ) #NEWLINE# print_menu_list ( chosen ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ri = get_input ( prompt , None , input ) #NEWLINE# #UNINDENT# except EOFError : #NEWLINE# #INDENT# return chosen #NEWLINE# #UNINDENT# if ( not ri ) : #NEWLINE# #INDENT# return chosen #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# idx = int ( ri ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# error ( 'Bad selection. Type in the number.' ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( idx < 0 ) : #NEWLINE# #INDENT# idx = ( ( - idx ) - 1 ) #NEWLINE# try : #NEWLINE# #INDENT# somelist . append ( chosen [ idx ] ) #NEWLINE# del idx [ idx ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# error ( 'Selection out of range.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( idx == 0 ) : #NEWLINE# #INDENT# error ( 'No zero.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# chosen . append ( somelist [ ( idx - 1 ) ] ) #NEWLINE# del somelist [ ( idx - 1 ) ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# error ( 'Selection out of range.' )