Skip to content

Instantly share code, notes, and snippets.

@un1t
Created March 24, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save un1t/f7c4096be6f36dd8126b to your computer and use it in GitHub Desktop.
Save un1t/f7c4096be6f36dd8126b to your computer and use it in GitHub Desktop.
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