Useful Python Trick: Interpreter Code-Complete

I was looking at the documentation and found this in the FAQ:

5. How can i get auto completion in python after loading the webpy module?

In IPython, after importing webpy auto completion may no longer work. You can still use ‘python’ with auto completion feature. Try it out directly. Fire up ‘python’:

import readline, rlcompleter
readline.parse_and_bind(“tab: complete”)

and tab it! :-)

To make in sort that this will be run default when you fire up ‘python’. Make a file called ‘~/’ and put the import line in it. Then set the ‘PYTHONSTARTUP’ environment variable to point to that file.

With my bash, i do it like following; edit ~/.bashrc and add:


I tried it and it works very nicely:

>>> os.f
os.fchdir os.fork os.fpathconf os.fsync
os.fdopen os.forkpty os.fstat os.ftruncate
>>> os.f