Tuesday, February 26, 2008

Python completion

If you want completion in Python console, just execute these two lines:
import readline, rlcompleter
readline.parse_and_bind("tab: complete")
Now completion works just like in bash. You could also set any other key than tab, but most will want exactly this.

If you want this to run automatically every time you run the python console, add those two lines to any file, for example into .pythonrc in your $HOME, and then set environment variable PYTHONSTARTUP in shell startup scripts (~/.bashrc, ~/.zshrc etc) to point to that file:
export PYTHONSTARTUP=$HOME/.pythonrc"

1 comments:

Anonymous said...

thanks, it works great and i <3 it :)