- Introduction to Python REPL
- Introduction to bpython
Python comes with a simple but really helpful interactive shell also know as REPL
read–eval–print loop. REPL allows us to quckly validate some ideas without the need to fire up the
IDE or Text Editor.
To start the python
REPL you can run
python command on your terminal.
➜ python Python 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 9.2.1 20191008] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
I am running ubuntu and it comes with Python 2, to run Python 3 I have to run python3
You can run normal statements or even create
But the problem with
REPL is that it doesn't come with color highlighting nor code completion. So, here comes bpython.
bpython is simply a python intepreter on steorid. It comes with great features like:
- Syntax highlighting
- Autocompletion and auto indentation
- Rewind function to undo last line
- Support for Docstring
Easiest method to install bpython is using
You can install bpython using the command
pip install bpython
If your computer also has python2 and you want to install bpython for python3 use
That's it, now you should be able to use bpython just by typing
bpython in your terminal.
bpython bpython version 0.18 on top of Python 3.7.5 /usr/bin/python3 >>>
Now we can see auto complete in action, someone said picture speaks 1000 words right? Let's see if that's true;
bpython -i file_name.py
I found bpython to be really helpful, I hope it's for you too.
Please let me know if I have missed some features of bython that you love.
See you in the next one.
In the mean time you can follow me on twitter