Thursday, May 8, 2014

Tab Tintinabulation


Enabling Tab Auto-Completion For Python

The Python Standard Library Reference on rlcompleter provides everything you need. Following the directions there here's what I did.
  1. Make a directory in your home directory
  2. ~$ mkdir .pythonrc
    
  3. Create a file in your new directory with the following lines
  4. ~/.pythonrc$ vim pythonstartup.py
    
    #! /usr/bin/env python
    try:
        import readline
    except ImportError:
        print "Module readline not available."
    else:
        import rlcompleter
        readline.parse_and_bind("tab: complete")
    
  5. Add the following line to your .bashrc file
  6. export PYTHONSTARTUP=~/.pythonrc/pythonstartup.py
    
  7. restart your shell and start python
Fork me on GitHub