How To Enable Auto-Completion in Python Shell

Learn how to use TAB to auto-complete expressions in plain vannila Python shell.

If you need to have auto completion in Python shell (almost the same way as iPython), it's very easy.
  1. Create a file named .pyreadline with the following content and put it in your home directory.
    #!python
    
    import rlcompleter, readline
    readline.parse_and_bind('tab: complete')
  2. Export the file as PYTHONSTARTUP variable; for example append it to .bashrc.
    echo "export PYTHONSTARTUP=~/.pyreadline" >> ~/.bashrc

Comments

Popular posts from this blog

Variables in GNU Make: Simple and Recursive

Checkmate on Your Terms: A Personal Journey with Correspondence Chess

Firefox profiles: Quickly replicate your settings to any machine