Skip to main content

No project description provided

Project description

https://img.shields.io/pypi/v/bpython https://readthedocs.org/projects/bpython/badge/?version=latest https://img.shields.io/badge/code%20style-black-000000.svg

bpython: A fancy curses interface to the Python interactive interpreter

bpython is a lightweight Python interpreter that adds several features common to IDEs. These features include syntax highlighting, expected parameter list, auto-indentation, and autocompletion. (See below for example usage).

bpython

bpython does not aim to be a complete IDE - the focus is on implementing a few ideas in a practical, useful, and lightweight manner.

bpython is a great replacement to any occasion where you would normally use the vanilla Python interpreter - testing out solutions to people’s problems on IRC, quickly testing a method of doing something without creating a temporary file, etc.

You can find more about bpython - including full documentation - at our homepage.

Installation & Basic Usage

Installation using Pip

If you have pip installed, you can simply run:

$ pip install bpython

Start bpython by typing bpython in your terminal. You can exit bpython by using the exit() command or by pressing control-D like regular interactive Python.

Installation via OS Package Manager

The majority of desktop computer operating systems come with package management systems. If you use one of these OSes, you can install bpython using the package manager.

Ubuntu/Debian

Ubuntu/Debian family Linux users can install bpython using the apt package manager, using the command with sudo privileges:

$ apt install bpython

In case you are using an older version, run

$ apt-get install bpython
Arch Linux

Arch Linux uses pacman as the default package manager; you can use it to install bpython:

$ pacman -S bpython
Fedora

Fedora users can install bpython directly from the command line using dnf.

$ dnf install bpython
Windows

Caveats: As bpython makes use of the ncurses library of *nix-family operating systems, bpython on Windows is not officially supported and tested.

However, you may still use bpython on Windows using a workaround. In brief, you should install these two packages using pip:

$ pip install bpython windows-curses

Then you should invoke a program called bpython-curses.exe instead of bpython.exe to use bpython:

$ bpython-curses
Mac OS

Like Windows, Mac OS does not include a package manager by default. If you have installed any third-party package manager like MacPorts, you can install it via

$ sudo port install py-bpython

Features & Examples

  • Readline-like autocomplete, with suggestions displayed as you type.

  • In-line syntax highlighting. This uses Pygments for lexing the code as you type, and colours appropriately.

  • Expected parameter list. As in a lot of modern IDEs, bpython will attempt to display a list of parameters for any function you call. The inspect module (which works with any Python function) is tried first, and then pydoc if that fails.

  • Rewind. This isn’t called “Undo” because it would be misleading, but “Rewind” is probably as bad. The idea is that the code entered is kept in memory and when the Rewind function is called, the last line is popped and the entire session is re-evaluated. Use <control-R> to rewind.

  • Edit the current line or your entire session in an editor. F7 opens the current session in a text editor, and if modifications are made, the session is rerun with these changes.

  • Pastebin code/write to file. Use the <F8> key to upload the screen’s contents to pastebin, with a URL returned.

  • Reload imported Python modules. Use <F6> to clear sys.modules and rerun your session to test changes to code in a module you’re working on.

Configuration

See the sample-config file for a list of available options. You should save your config file as ~/.config/bpython/config (i.e. $XDG_CONFIG_HOME/bpython/config) or specify at the command line:

bpython --config /path/to/bpython/config

Dependencies

  • Pygments

  • curtsies >= 0.3.5

  • greenlet

  • pyxdg

  • requests

  • Sphinx >= 1.5 (optional, for the documentation)

  • babel (optional, for internationalization)

  • jedi (optional, for experimental multiline completion)

  • watchdog (optional, for monitoring imported modules for changes)

  • pyperclip (optional, for copying to the clipboard)

bpython-urwid

bpython-urwid requires the following additional packages:

  • urwid

Known Bugs

For known bugs please see bpython’s known issues and FAQ page.

Contact & Contributing

I hope you find it useful and please feel free to submit any bugs/patches suggestions to Robert or place them on the GitHub issues tracker.

For any other ways of communicating with bpython users and devs you can find us at the community page on the project homepage, or in the community.

Hope to see you there!

CLI Windows Support

Dependencies

Curses Use the appropriate version compiled by Christoph Gohlke.

pyreadline Use the version in the cheeseshop.

Current version is tested with

  • Curses 2.2

  • pyreadline 1.7

Curses Notes

The curses used has a bug where the colours are displayed incorrectly:

  • red is swapped with blue

  • cyan is swapped with yellow

To correct this I have provided a windows.theme file.

This curses implementation has 16 colors (dark and light versions of the colours)

Alternatives

ptpython

IPython

Feel free to get in touch if you know of any other alternatives that people may be interested to try.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpython-0.22.tar.gz (217.2 kB view details)

Uploaded Source

Built Distribution

bpython-0.22-py3-none-any.whl (187.9 kB view details)

Uploaded Python 3

File details

Details for the file bpython-0.22.tar.gz.

File metadata

  • Download URL: bpython-0.22.tar.gz
  • Upload date:
  • Size: 217.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for bpython-0.22.tar.gz
Algorithm Hash digest
SHA256 6786163c26546f16f08dabdcc6b85d12b21a9ea5f039d24479e73cc8a003d0f7
MD5 e01ba913d8369c58625b3a66bd346595
BLAKE2b-256 cb110c221e949172bf8f7156179ba0a05511fd3c5136801008866592c093742c

See more details on using hashes here.

File details

Details for the file bpython-0.22-py3-none-any.whl.

File metadata

  • Download URL: bpython-0.22-py3-none-any.whl
  • Upload date:
  • Size: 187.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for bpython-0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 8a052068918f7acb1428ecee74ce3299605e8e57a128f4c25d905903dd08aeab
MD5 80ee13ff6f400adb6b1da7c927cffb3b
BLAKE2b-256 2a35b4174fffd174979c44874074e934279495253a0731fc3dbcb61592e915eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page