Ptpython - A Python REPL You will Love!

ptpython brings some of the most valuable features to your Python shell and it is one of the most advanced python REPL out there which works on all Python versions from 2.6 up to 3.6+ and is cross-platform (Linux, BSD, OS X and Windows).

Posted by Mohit on February 06, 2018   3210 views

Imagine you are debugging in your python shell and in order to do that you defined a function but as soon as you press Enter in the end, what you see that you made a Syntax error, Now you have to re-edit the whole function again (Good luck!). Can you go one line above and change something while defining a block of code like function, class etc in your shell (Obviously you can't :P). Well, these are some of the problems that are solved by ptpython.

First, let me tell you what ptpython offers:

  • Syntax highlighting.
  • Multiline editing (the up arrow works).
  • Search and Reverse Search
  • History Browser
  • Autocompletion.
  • Documentation Popups
  • Mouse support.
  • Support for color schemes.
  • Both Vi and Emacs key bindings.
  • Custom keybinds
  • ... and much other stuff

This is how it looks...




Looks Great? Let's get done with the installation part first.

pip install ptpython

Then copy this file to ~/.ptpython/ , this file contains different configuration settings which you can modify according to your preference. 

Now just type ptpython in your terminal or cmd to try this awesome REPL. You can also embed ptpython by typing this in your python shell (Cool Right ?)

from ptpython.repl import embed
embed(globals(), locals())

You can also use ptpython as your Django shell with django-extensions

First, install ptpython then install django-extensions

pip install django-extensions

Add django-extensions to your installed apps


Then in terminal, type python shell_plus --ptpython (You can leave off "--ptpython" if you haven't installed any other python repl like bpython etc)

If you like this post please share or leave a comment.

blog comments powered by Disqus