Re: tab compleation input

2006-11-13 Thread Eli Criffield
#Thanks for the link from Fredrik Lundh #from http://effbot.org/librarybook/readline.htm #You do it like this, class Completer: def __init__(self, words): self.words = words self.prefix = None def complete(self, prefix, index): if prefix != self.prefix:

Re: tab compleation input

2006-11-13 Thread Fredrik Lundh
Eli Criffield wrote: > Not sure what your trying to do, but it doesn't work. :) > valid doesn't exsist it's assigned to by the for-in loop, and is only used inside it. > Either way, it doesn't take the tab tell after you hit enter, Not > really what i was getting at. What i want is like a bash s

Re: tab compleation input

2006-11-13 Thread ZeD
Eli Criffield wrote: > 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. I think you may "play" width curses library: readline() read... while you input a "newline", but you need to catch single keys (the "TAB" key, foremost) --

Re: tab compleation input

2006-11-13 Thread Eli Criffield
Not sure what your trying to do, but it doesn't work. :) valid doesn't exsist, and if you make vaid = sys.stdin.readline().rstrip(), then answer doesn't exsist. Either way, it doesn't take the tab tell after you hit enter, Not really what i was getting at. What i want is like a bash shell prompt

Re: tab compleation input

2006-11-13 Thread [EMAIL PROTECTED]
On a gui on this would be a little bit easier but it's a completley diffrent realm when doing it in the console. It makes it a little more difficult when using stdin.readline() because you can only read line by line. Here is my implmentation. import sys validanswers = [ 'yes', 'no', 'maybe', 'tue

tab compleation input

2006-11-13 Thread Eli Criffield
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 : --snip-- validanswers = [ 'yes', 'no', 'maybe', 'tuesday', 'never' ] #and i ask sys.stdout.write("Answer the Question: ") answer = sys.stdin.readline().rstrip() if ans