LinuxCommandLibrary

bpython

Interactive Python interpreter with autocompletion

TLDR

Start a REPL (interactive shell)

$ bpython
copy

Execute a specific Python file
$ bpython [path/to/file.py]
copy

Execute a specific Python file and start a REPL
$ bpython [[-i|--interactive]] [path/to/file.py]
copy

Use the specified configuration file instead of the default configuration
$ bpython --config [path/to/file.conf]
copy

SYNOPSIS

bpython [options] [scriptfile] [args]
or
bpython [options] -c command [args]

PARAMETERS

-h, --help
    Show program's help message and exit.

-V, --version
    Show program's version number and exit.

-i INTERPRETER, --interpreter INTERPRETER
    Use a specific Python interpreter executable, e.g., /usr/bin/python3.

-c CONFIG, --config CONFIG
    Use an alternative configuration file instead of the default.

-p, --pastebin
    Automatically upload the session content to a pastebin service on exit.

-o OUTPUT, --output OUTPUT
    Write the entire session's output to a specified file on exit.

--curses
    Force the use of the curses-based full-screen interface (often the default).

--cli
    Force the use of the simpler command-line interface, which lacks some advanced features.

--urwid
    Force the use of the urwid-based interface.

DESCRIPTION

bpython is a sophisticated, interactive Python interpreter that aims to provide a richer and more user-friendly experience than the standard Python shell. It offers a range of features designed to boost productivity and reduce common frustrations during interactive coding sessions. Key functionalities include inline autocompletion for attributes, methods, and built-in functions, syntax highlighting as you type, and a unique 'rewind' feature that allows you to undo previous statements and their side effects. It also integrates with external services like pastebin for easily sharing code snippets and provides intelligent indentation. bpython typically runs in a terminal using a curses-based interface, but also offers simpler command-line and urwid-based interfaces. It's an excellent tool for rapid prototyping, learning Python, and debugging.

CAVEATS

Due to its reliance on curses or urwid, bpython's rendering might vary across different terminal emulators or operating systems. It may have a slightly longer startup time compared to the plain Python interpreter, and its 'rewind' feature might not fully undo side effects of certain complex operations or external interactions.

KEY BINDINGS

bpython utilizes several function keys for quick access to its features:
F1: Help
F2: Configuration
F3: Clear screen
F4: Rewind (undo last statement)
F5: Pastebin (upload session)
F8: Save (save session to file)
F9: Toggle paste mode
F10: Quit

CONFIGURATION

bpython's behavior can be extensively customized via a configuration file, typically located at ~/.config/bpython/config or ~/.bpython/config. This file allows users to define key bindings, change color schemes, enable/disable features like autocompletion and syntax highlighting, and configure pastebin options.

HISTORY

bpython was initially created by Robert Collins and first released around 2008. It was conceived as a highly interactive and user-friendly alternative to the standard Python REPL (Read-Eval-Print Loop), focusing on providing immediate visual feedback and powerful navigation capabilities that were not present in other tools at the time. Its development has focused on enhancing the interactive coding experience for Python programmers.

SEE ALSO

python(1), ipython(1)

Copied to clipboard