|
| 1 | +[<img src="https://img.shields.io/pypi/v/bpython">](https://pypi.org/project/bpython) |
| 2 | +[<img src="https://readthedocs.org/projects/bpython/badge/?version=latest">](https://docs.bpython-interpreter.org/en/latest/) |
| 3 | +[<img src="https://img.shields.io/badge/code%20style-black-000000.svg">](https://github.com/ambv/black) |
| 4 | + |
| 5 | +# bpython: A fancy interface to the Python interactive interpreter |
| 6 | + |
| 7 | +``bpython`` is a lightweight Python interpreter that adds several features common |
| 8 | +to IDEs. These features include **syntax highlighting**, **expected parameter |
| 9 | +list**, **auto-indentation**, and **autocompletion**. (See below for example |
| 10 | +usage). |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +bpython does **not** aim to be a complete IDE - the focus is on implementing a |
| 15 | +few ideas in a practical, useful, and lightweight manner. |
| 16 | + |
| 17 | +bpython is a great replacement to any occasion where you would normally use the |
| 18 | +vanilla Python interpreter - testing out solutions to people's problems on IRC, |
| 19 | +quickly testing a method of doing something without creating a temporary file, |
| 20 | +etc. |
| 21 | + |
| 22 | +You can find more about bpython - including [full documentation](https://docs.bpython-interpreter.org) - at our |
| 23 | +[homepage](https://bpython-interpreter.org). |
| 24 | + |
| 25 | +## Installation using Pip |
| 26 | + |
| 27 | +If you have [pip](https://pip.pypa.io/en/latest/index.html) installed, you can simply run: |
| 28 | + |
| 29 | +```bash |
| 30 | +$ pip install bpython |
| 31 | +``` |
| 32 | + |
| 33 | +Start bpython by typing ``bpython`` in your terminal. You can exit bpython by |
| 34 | +using the ``exit()`` command or by pressing control-D like regular interactive |
| 35 | +Python. |
| 36 | + |
| 37 | +## Features & Examples |
| 38 | + |
| 39 | +- Readline-like autocomplete, with suggestions displayed as you type. |
| 40 | +- In-line syntax highlighting. This uses Pygments for lexing the code as you |
| 41 | + type, and colours appropriately. |
| 42 | +- Expected parameter list. As in a lot of modern IDEs, bpython will attempt to |
| 43 | + display a list of parameters for any function you call. The inspect module (which |
| 44 | + works with any Python function) is tried first, and then pydoc if that fails. |
| 45 | +- Rewind. This isn't called "Undo" because it would be misleading, but "Rewind" |
| 46 | + is probably as bad. The idea is that the code entered is kept in memory and |
| 47 | + when the Rewind function is called, the last line is popped and the entire |
| 48 | + session is re-evaluated. Use <control-R> to rewind. |
| 49 | +- Edit the current line or your entire session in an editor. F7 opens the current |
| 50 | + session in a text editor, and if modifications are made, the session is rerun |
| 51 | + with these changes. |
| 52 | +- Pastebin code/write to file. Use the <F8> key to upload the screen's contents |
| 53 | +- to pastebin, with a URL returned. |
| 54 | +- Reload imported Python modules. Use <F6> to clear sys.modules and rerun your |
| 55 | + session to test changes to code in a module you're working on. |
| 56 | + |
| 57 | +## Configuration |
| 58 | + |
| 59 | +See the sample-config file for a list of available options. You should save |
| 60 | +your config file as **~/.config/bpython/config** (i.e. |
| 61 | +``$XDG_CONFIG_HOME/bpython/config``) or specify at the command line: |
| 62 | + |
| 63 | +``` |
| 64 | +bpython --config /path/to/bpython/config |
| 65 | +``` |
| 66 | + |
| 67 | +## Dependencies |
| 68 | + |
| 69 | +- Pygments |
| 70 | +- curtsies >= 0.3.5 |
| 71 | +- greenlet |
| 72 | +- pyxdg |
| 73 | +- requests |
| 74 | +- Sphinx >= 1.5 (optional, for the documentation) |
| 75 | +- babel (optional, for internationalization) |
| 76 | +- jedi (optional, for experimental multiline completion) |
| 77 | +- watchdog (optional, for monitoring imported modules for changes) |
| 78 | +- pyperclip (optional, for copying to the clipboard) |
| 79 | + |
| 80 | +### bpython-urwid |
| 81 | + |
| 82 | +``bpython-urwid`` requires the following additional packages: |
| 83 | + |
| 84 | +- urwid |
| 85 | + |
| 86 | + |
| 87 | +## Installation via OS Package Manager |
| 88 | + |
| 89 | +The majority of desktop computer operating systems come with package management |
| 90 | +systems. If you use one of these OSes, you can install ``bpython`` using the |
| 91 | +package manager. |
| 92 | + |
| 93 | +### Ubuntu/Debian |
| 94 | + |
| 95 | +Ubuntu/Debian family Linux users can install ``bpython`` using the ``apt`` |
| 96 | +package manager, using the command with ``sudo`` privileges: |
| 97 | + |
| 98 | +```bash |
| 99 | +$ apt install bpython |
| 100 | +``` |
| 101 | + |
| 102 | +In case you are using an older version, run |
| 103 | + |
| 104 | +```bash |
| 105 | +$ apt-get install bpython |
| 106 | +``` |
| 107 | + |
| 108 | +### Arch Linux |
| 109 | + |
| 110 | +Arch Linux uses ``pacman`` as the default package manager; you can use it to install ``bpython``: |
| 111 | + |
| 112 | +```bash |
| 113 | +$ pacman -S bpython |
| 114 | +``` |
| 115 | + |
| 116 | +### Fedora |
| 117 | + |
| 118 | +Fedora users can install ``bpython`` directly from the command line using ``dnf``. |
| 119 | + |
| 120 | +```bash |
| 121 | +$ dnf install bpython |
| 122 | +``` |
| 123 | + |
| 124 | +### macOS |
| 125 | + |
| 126 | +macOS does not include a package manager by default. If you have installed any |
| 127 | +third-party package manager like MacPorts, you can install it via |
| 128 | + |
| 129 | +```bash |
| 130 | +$ sudo port install py-bpython |
| 131 | +``` |
| 132 | + |
| 133 | +## Known Bugs |
| 134 | + |
| 135 | +For known bugs please see bpython's [known issues and FAQ](http://bpython-interpreter.org/known-issues-and-faq.html) |
| 136 | +page. |
| 137 | + |
| 138 | +## Contact & Contributing |
| 139 | +I hope you find it useful and please feel free to submit any bugs/patches |
| 140 | +on the GitHub [issue tracker](http://github.com/bpython/bpython/issues/). |
| 141 | + |
| 142 | +For any other ways of communicating with bpython users and devs you can find us |
| 143 | +at the community page on the [project homepage](https://bpython-interpreter.org), |
| 144 | +or in the [community](https://docs.bpython-interpreter.org/community.html). |
| 145 | + |
| 146 | +Hope to see you there! |
0 commit comments