Discover bpython: Python REPL With IDE-Like Features

Discover bpython: A Python REPL With IDE-Like Features

by Bartosz Zaczyński Reading time estimate 47m intermediate editors tools

The standard Python interpreter lets you run scripts from files or interactively execute code on the fly in a so-called read-evaluate-print loop (REPL). While this is a powerful tool for exploring the language and discovering its libraries through instant feedback on your code inputs, the default REPL shipped with Python has several limitations. Luckily, alternatives like bpython offer a much more programmer-friendly and convenient experience.

You can use bpython to experiment with your code or quickly test an idea without switching contexts between different programs, just like in an integrated development environment (IDE). In addition, bpython may be a valuable teaching tool in either a virtual or physical classroom.

In this tutorial, you’ll learn how to:

  • Install and use bpython as your alternative Python REPL
  • Boost your productivity thanks to bpython’s unique features
  • Tweak bpython’s configuration and its color theme
  • Use common keyboard shortcuts to code more quickly
  • Contribute to bpython’s open-source project on GitHub

Before starting this tutorial, make sure you’re already familiar with Python basics and know how to start the standard Python REPL in the command line. In addition, you should be able to install packages with pip, ideally into a virtual environment.

To download the configuration files and sample scripts that you’ll use in this tutorial, click the link below:

Get Started With bpython

Unlike stand-alone Python distributions, such as CPython, PyPy, or Anaconda, bpython is merely a pure-Python package serving as a lightweight wrapper around a chosen Python interpreter. Therefore, you can use bpython on top of any particular Python distribution, version, or even a virtual environment, which gives you plenty of flexibility.

At the same time, bpython remains a familiar Python REPL with only a few essential features, such as syntax highlighting and auto-completion, borrowed from the full-fledged Python IDEs. This minimalistic approach contrasts with tools like IPython, which is yet another alternative to the standard Python REPL, popular in the data science community. IPython introduces a lot of custom commands and other extras that are unavailable in vanilla Python.

There are a few ways to get bpython on your computer. Package managers like Homebrew or APT offer pre-built versions of bpython for your operating system. However, they’re likely obsolete and hardwired to the system-wide Python interpreter. While you can build the latest bpython version from its source code by hand, it’s better to install it into a virtual environment with pip:

Language: Shell