Tab completion in Python interpreter

I wanted to have tab-completion for my python interpreter at startup and this just worked out.

$ export PYTHONSTARTUP=$HOME/.mypythonstartup

$ vi ~/.mypythonstartup

import rlcompleter
import readline

readline.parse_and_bind(“tab: complete”)

Now I am able to do tab-complete the python functions and keywords in my python interpreter.

But this holds only for this session of the terminal. To make it available always, edit the .bashrc file as follows.

$ vi ~/.bashrc

export PYTHONSTARTUP=$HOME/.mypythonstartup

And ’tis done !! Cheers….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s