Skip to content

Instantly share code, notes, and snippets.

@danse
Created January 24, 2012 15:41
Show Gist options
  • Save danse/1670750 to your computer and use it in GitHub Desktop.
Save danse/1670750 to your computer and use it in GitHub Desktop.
Add autocompletion to python shell
To add autocompletion to the python shell, add the following export into your .bashrc file:
export PYTHONSTARTUP=/home/<user>/.pythonstartup
Where <user> is your username, and .pythonstartup is a file containing the following two lines:
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
To test if the change worked, start a python shell and type
>>> import sys
>>> sys.
Then type Tab. A completion list should appear.
Reference: http://docs.python.org/release/2.6.6/tutorial/interactive.html#key-bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment