Created
March 24, 2015 18:43
-
-
Save un1t/f7c4096be6f36dd8126b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import readline | |
texts = ['hello', 'world', 'readline'] | |
def completer(text, state): | |
options = [x for x in texts if x.startswith(text)] | |
try: | |
return options[state] | |
except IndexError: | |
return None | |
readline.set_completer(completer) | |
readline.parse_and_bind("tab: complete") | |
while 1: | |
a = raw_input("> ") | |
print "You entered", a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment