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
- 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/config.py , 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
ptpython then install
pip install django-extensions
django-extensions to your installed apps
INSTALLED_APPS = ( ... 'django_extensions', )
Then in terminal, type
python manage.py 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