Registry / testing / bpython

bpython

JSON →
library0.26pypypi✓ verified 35d ago

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.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The primary way to use bpython is by running it directly from your terminal.

$ bpython

The 'embed' function is typically imported directly from the bpython package for programmatic use. Direct import of bpython.embed as a module might work but is not the idiomatic way to access the function.

from bpython import embed

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.")
bpython --version
Debug
Known footguns
breakingbpython version 0.26 and newer dropped support for Python 3.9. If you are on Python 3.9, you must use an older version of bpython (e.g., 0.25) or upgrade your Python interpreter. This contradicts the general PyPI 'requires_python: >=3.9' but is explicit in release notes.
breakingThe `bpython-cli` rendering backend was entirely removed in version 0.25, following its deprecation in 0.19. If you were explicitly using this backend, your setup will break.
breakingSupport for Python 2 was completely dropped in version 0.21. Attempts to run bpython 0.21 or newer with Python 2 will fail.
breakingSupport for Python 3.7 and 3.8 was dropped in version 0.25. Users on these Python versions must use an older bpython release (e.g., 0.24) or upgrade their Python interpreter.
gotchaFor clipboard functionality (copy/paste from/to bpython), the `pyperclip` package must be installed separately. Without it, clipboard operations will not work.
gotchaPrior to version 0.22, the `bpython.embed()` function did not correctly honor local variables passed to it when embedded within a script. This meant the embedded session might not have access to the expected local scope.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources