Most Python developers use a shell, or REPL (Read-Eval-Print-Loop) to quickly try out small bits of code and also for quick and dirty debugging.
python in your command line and hit enter. That should bring up the default Python shell. You should see something like this:
Python 3.5.2 (default, Sep 28 2016, 18:11:34) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>
(If you've never done this before, try entering any Python code.)
That's very nice, but did you know there are other Python shells?
My favourite shell is called
ptipython. It combines
ptpython and it's very cool. See here for a screenshot:
The Github repository contains most of the information, but let me show you a few basics.
pip install ptipython to install this.
Some cool features
ptipython shell comes with autocompletion and suggestions. Press F2 (or
cmd + F2) to bring up the settings for it. Alternatively, you could also configure
Here's how it appears for me:
Another cool feature, is that if you put
? after a symbol (an object, module, class, function, or method), it brings up some basic information like the docstring. If you put two question marks (
??) it shows you the code:
Use it with Django
If you do web development in Django, you could also replace the default Django shell with
The way to do this is to install
django_extensions by typing
pip install django_extensions, and then adding
INSTALLED_APPS. Then type this to bring up the shell:
python manage.py shell_plus --ptipython
Hope you found this useful. Enjoy!