The promise of the open source programming language Python for numerical computing has been frustrating for lack of good, consolidated advice out there to troubleshoot issues that should be really simple. Here’s a brief tutorial on how to get readline support on Mac OS X 10.5.x.
What is readline? Readline is a program that allows you to use tab completion, history, and other features that you’re used to in your favorite shell, MATLAB from the command line, and GNU Octave.
There are two steps to this. The first is to tell python to always use a startup file. The second is the create the startup file with the right info inside. I’m assuming you use Bash and are running python from a terminal — in xterm, Terminal.app, or iTerm.app, etc.
Step 1: In your .bashrc file (or .profile, .bash_profile, etc.), using your favorite text editor, put the following line:
To initialize this, at your shell, type:
(substitute your file appropriately)
Step 2: Create the file .pythonrc in your home directory (~/):
readline.parse_and_bind ("tab: complete")
Save this file, and now run any python build you may have on your machine. Python will read this file automatically and now you can test out tab completion by typing (no quotes): ‘imp’. The word “import” should be completed.