How do I add tab completion to the Python shell? How do I add tab completion to the Python shell? python python

How do I add tab completion to the Python shell?


I may have found a way to do it.

Create a file .pythonrc

# ~/.pythonrc# enable syntax completiontry:    import readlineexcept ImportError:    print("Module readline not available.")else:    import rlcompleter    readline.parse_and_bind("tab: complete")

then in your .bashrc file, add

export PYTHONSTARTUP=~/.pythonrc

That seems to work.


I think django does something like https://docs.python.org/library/rlcompleter.html

If you want to have a really good interactive interpreter have a look at IPython.