loading...
Cover image for Bpython: Python REPL on steroids.

Bpython: Python REPL on steroids.

paurakhsharma profile image Paurakh Sharma Humagain ・2 min read

Table of Contents

Introduction to Python REPL

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 Class or Function inside REPL.

But the problem with REPL is that it doesn't come with color highlighting nor code completion. So, here comes bpython.


bython

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

Installing bpython

Easiest method to install bpython is using pip.

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 pip3 instead of pip

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
>>>

Python intepreter vs bpython

Now we can see auto complete in action, someone said picture speaks 1000 words right? Let's see if that's true;

bpython vs python intepreter autocomplete
bpython vs python intepreter docstring


You can undo the last line simply by pressing Ctrl+R.


You can also open and run a python file in bpython intepreter using the command.

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

Posted on by:

paurakhsharma profile

Paurakh Sharma Humagain

@paurakhsharma

Full-StackOverflow developer. I love instructing computers to do stuffs.

Discussion

pic
Editor guide
 

Does this offer anything compelling over iPython?

 

No it doesn't. I like it because it's lightweight compared to Ipython.

 

Yes iPython does take a lot to run for sure