Skip to content

Instantly share code, notes, and snippets.

@python-consulting
Last active August 29, 2015 13:56
Show Gist options
  • Save python-consulting/9227275 to your computer and use it in GitHub Desktop.
Save python-consulting/9227275 to your computer and use it in GitHub Desktop.
Enable interactive python auto completion on any platform
# -*- coding: utf-8 -*-
import sys
if sys.platform.startswith('linux'):
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
elif sys.platform.startswith('darwin'):
import readline
import rlcompleter
readline.parse_and_bind("bind ^I rl_complete")
elif sys.platform.startswith('win32'):
try:
import readline
except ImportError:
print "Install pyreadline package"
import rlcompleter
readline.parse_and_bind("tab: complete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment