bpython

0.26 · active · verified Wed Apr 15

bpython is a lightweight Python interpreter that provides a fancy curses-based interface to the standard Python REPL. It enhances the interactive experience with features such as syntax highlighting, expected parameter lists, auto-indentation, and autocompletion. It also includes unique functionalities like 'rewind' (undoing the last line), code pastebin, and in-editor session editing. The library is actively maintained, with version 0.26 being the latest release, and new versions often focus on supporting the latest Python releases.

Warnings

Install

Imports

Quickstart

While bpython is most commonly started by typing `bpython` in the terminal, you can also embed it programmatically within your Python scripts. This allows you to drop into an interactive bpython session at a specific point in your code, with access to local variables, useful for debugging or interactive exploration.

import bpython

def my_function(x, y):
    return x * y

print("Starting bpython embedded session...")
# You can pass a dictionary of local variables to the embed function
bpython.embed(locals={'my_func': my_function, 'value': 10})
print("Exited bpython embedded session.")

view raw JSON →