bpython Alternative Shell Review
bpython is a lighter solution than IPython, which we discussed last time; where IPython expands the capabilities of Python itself, and offers interactive features as a sideline, bpython expands the interactive features of Python's shell — and that's about it. Within the bounds of its intended purpose, however, it is quite good. It works on Windows, Linux, and OS X. Although installation on Windows is a real pain.
Like IPython, bpython offers two interfaces, a command-line interface using curses and one using GTK. Testing the two suggests that the GTK interface has received rather less attention, and the command-line interface should be preferred in the version tested (0.9.7.1). Some specifics: pressing the Home key at the end of a line places the cursor before the prompt rather than after it, though when you type, it replaces the cursor correctly; using a dark GTK theme, the code-completion menus are completely black; and there are no keyboard shortcuts for menu functions.
bpython Code Completion and Syntax Highlighting
Code completion with bpython is somewhat nicer than with IPython's CLI interface; rather than simply presenting a list for you to type, it gives you a list that you can scroll through using Tab and Shift-Tab. It also handles the case of extremely long lists of suggestions gracefully, though one could wish for arrow-key and page up/down navigation. The GTK interface is no more convenient — all the items are presented in a single list that shows only about 10 items at once, and can be navigated using arrow keys or Tab and Shift-Tab; navigating long lists in that manner is difficult, because you can't see far enough ahead to go quickly. Function signature assistance is provided simply and effectively.
bpython highlights syntax as you type, and in source-code listings. It does it cleanly, quickly, and effectively using Pygments. The colors used can be customized by creating a theme file, which is dead simple; there's a good example given in the download tarball.
Help in bpython is fairly minimal — you can use the
help function provided by the basic Python interactive mode, and you can show the source of the current function.
help function works exactly as in the default Python interpreter, which is to say rather well. It uses a pager to show the definition and docstring for the item for which help is requested, and does no syntax highlighting in the result.
Showing the source of a function or class definition is effective when it works, though it seems to have problems finding the source of functions that have been defined interactively. It does a good job presenting the source of imported modules, however, and presents them in a pager with syntax highlighting.
Other Functions of bpython
You can save an interactive session to a file using Ctrl-S, or send it to a pastebin (the bpython developers' own is hard-coded) using F8. Both work just fine, although they include lines that produced errors when initially issued; it would be nice to have an option to exclude them.
There is also an un-intuitively named Rewind function, which takes all lines issued so far, pops off the last one, and re-evaluates the remainder. This is potentially dangerous for code with side-effects, and even though I've found it to be useful, it still gives me the creeps. I suppose it works on the "fail bravely" principle.
bpython Review Summary
Despite the warts here and there, and its idiosyncratic selection of functionality, I've found bpython very useful; so useful, in fact, that I have a keyboard shortcut mapped on all my machines to open it. If you find, as I have, that IPython doesn't really fit your style, give bpython a try; you might be pleasantly surprised.
DreamPie Alternative Shell Review
DreamPie — why must everything Python have ridiculous names? — is, like bpython, focused on improving interactive use of Python. It was written by a contributor to IDLE, the pseudo-IDE supplied by default with Python, and includes some code from IDLE.
DreamPie's layout is not like that of the default Python interactive console, or the others we have already discussed. Instead of the user entering code and seeing output on alternate lines, DreamPie is divided into two sections, top and bottom: code is entered in the bottom one, and when it is submitted, it is evaluated in the top section. (For Scheme programmers, it feels rather like DrRacket's interface, except there is no file-based text editor section.)
The advantage of this layout is that code entered in the lower section can fill as many lines as required before it is submitted; that allows multi-line editing, a frequently-felt lack in other interactive consoles, and obviates the need for bpython's quirky Rewind function. For example, you can enter an entire function definition:
for i in range(n):
print n * scale
Then, when you realize that you forgot the
scale parameter in the first line, you don't have to re-enter the entire function; you can just go up and change the first line to
def some_func(n, scale). When you're finished, hit Ctrl+Enter to submit the entire block.
This is really DreamPie's killer feature — all the rest is gravy. But it's tasty gravy. Read on.
DreamPie Syntax Highlighting and Code Completion
Everywhere there is syntax, DreamPie highlights it. It does it quickly and well, and there is consistency between the in-progress highlighting in the code window and the static highlighting in the evaluation window. In short, syntax highlighting works.
Code completion for all the interactive Python shells discussed here is technically flawless: they all present about the same information, and complete keywords, names, module names, properties — everything. DreamPie excels in its user interface, however; it is much easier to navigate long lists of completions, and the signature help is brilliant — where available, it shows the entire source of the function or class in a scrollable window.
DreamPie offers about as much help as bpython, which is to say, not much. You can use the
help function, and the call tips and signature help with full source is nice, but that's about all the Python help it provides. There is also little documentation, but the menus are logically arranged, functionality is well-named, and keyboard shortcuts are listed in the menus; there's not much more to document, though a handy manual would be appreciated.
Other Functions of DreamPie
DreamPie has a well thought-out selection of additional features, some of which are very helpful. One of the most effective of those is the Copy Code Only function; it allows the user to select a region in the evaluation area, and copy only the code to the clipboard, with the evaluated results omitted. I find myself using that frequently, but I wish there were an analogous option that saves the code in the region to a file. (I've submitted a pull request to add that functionality, but it has not yet been accepted or rejected.)
You can save the history to an HTML file that preserves the highlighting and layout of the DreamPie interface, and import history from saved HTML. An option to save as plain text would also be appreciated, but is not evident if it exists.
Another feature DreamPie offers is multiple tabs — but for some reason the only tabbed area is the code entry section. I find myself wanting to have separate evaluation panes for each code-entry tab, but that may be more involved to implement than it's worth. At any rate, this feature has not proved itself useful in my trial.
DreamPie Review Summary
DreamPie is clean, simple, and mostly well-executed, and its division of code entry and evaluation alone is enough to justify trying it. I've found it effective and bug-free, and it is simple to set up on all operating systems.
The final advice I can offer is this: if you need IPython, you probably know that, and it's the obvious choice for you. bpython and DreamPie have about the same capabilities, and they are both reliable and simple to use; the only distinguishing feature is the standard terminal experience offered by bpython versus DreamPie's divided window. If you know which of those fits your preferences best, choose accordingly; otherwise, try both and see.
No matter what, you'll have a much better experience than the default Python console.To Practice: Try this interactive course on the basics of Lists, Functions, Packages and NumPy in Python.