tab compleation input

Eli Criffield elicriffield at
Mon Nov 13 17:11:28 CET 2006

Here is what i want to do. I have a question in my program, and i want
to do tab completion for the valid answers.

Say i have :
validanswers = [ 'yes', 'no', 'maybe', 'tuesday', 'never' ]

#and i ask

sys.stdout.write("Answer the Question: ")
answer = sys.stdin.readline().rstrip()
if answer not in valid answers:
  print "Wrong!"

But what i want is when i enter the answer i can hit tab and it'll
complete one of the validanswers
I know i can do tab complete with readline and 'raw_input('> ')' but
that's only to execute python commands right?


More information about the Python-list mailing list