|
| 1 | +bpython - A fancy curses interface to the Python interactive interpreter |
| 2 | +======= |
| 3 | + |
| 4 | +Dependencies |
| 5 | +============ |
| 6 | +Pygments |
| 7 | +pyparsing |
| 8 | +(apt-get install python-pyparsing python-pygments) |
| 9 | + |
| 10 | +Introduction |
| 11 | +============ |
| 12 | +A few people asked for stuff like syntax highlighting |
| 13 | +and autocomplete for the Python interactive interpreter. |
| 14 | +IPython seems to offer this (plus you can get readline |
| 15 | +behaviour in the vanilla interpreter) but I tried |
| 16 | +IPython a couple of times. Perhaps I didn't really get |
| 17 | +it, but I get the feeling that the ideas behind IPython |
| 18 | +are pretty different to bpython. I didn't want to create |
| 19 | +a whole development environment; I simply wanted to |
| 20 | +provide a couple of neat features that already exist |
| 21 | +and turn them into something a little more interactive. |
| 22 | + |
| 23 | +The idea is to provide the user with all the features |
| 24 | +in-line, much like modern IDEs, but in a simple, |
| 25 | +lightweight package that can be run in a terminal |
| 26 | +window, so curses seemed like the best choice. |
| 27 | +Sorry if you use Windows. |
| 28 | + |
| 29 | +bpython doesn't attempt to create anything new or |
| 30 | +groundbreaking, it simply brings together a few neat |
| 31 | +ideas and focuses on practicality and usefulness. |
| 32 | +For this reason, the "Rewind" function should be |
| 33 | +taken with a pinch of salt, but personally I have |
| 34 | +found it to be very useful. I use bpython now |
| 35 | +whenever I would normally use the vanilla interpreter, |
| 36 | +e.g. for testing out solutions to people's problems |
| 37 | +on IRC, quickly testing a method of doing something |
| 38 | +without creating a temporary file, etc.. |
| 39 | + |
| 40 | +I hope you find it useful and please feel free to |
| 41 | +submit any bugs/patches (yeah right)/suggestions |
| 42 | +to: |
| 43 | +robertanthonyfarrell@gmail.com |
| 44 | + |
| 45 | +Features |
| 46 | +======== |
| 47 | + |
| 48 | +* In-line syntax highlighting. |
| 49 | + This uses Pygments for lexing the code as you type, |
| 50 | + and colours appropriately. Pygments does a great job |
| 51 | + of doing all of the tricky stuff and really leaving |
| 52 | + me with very little to do except format the tokens |
| 53 | + in all my favourite colours. |
| 54 | + |
| 55 | +* Readline-like autocomplete with suggestions displayed |
| 56 | +as you type. |
| 57 | + Thanks to Python's readline interface to libreadline |
| 58 | + and a ready-made class for using a Python interpreter's |
| 59 | + scope as the dataset, the only work here was displaying |
| 60 | + the readline matches as you type in a separate curses |
| 61 | + window below/above the cursor. |
| 62 | + |
| 63 | +* Expected parameter list. |
| 64 | + As in a lot of modern IDEs, bpython will attempt to |
| 65 | + display a list of parameters for any function you |
| 66 | + call. The inspect module is tried first, which works |
| 67 | + with any Python function, and then pydoc if that fails, |
| 68 | + which seems to be pretty adequate, but obviously |
| 69 | + in some cases it's simply not possible. I used pyparsing |
| 70 | + to cure my nested parentheses woes; again, it was |
| 71 | + nice and easy. |
| 72 | + |
| 73 | +* Rewind. |
| 74 | + I didn't call this "Undo" because I thought that would |
| 75 | + be misleading, but "Rewind" is probably as bad. The |
| 76 | + idea is that the code entered is kept in memory and |
| 77 | + when the Rewind function is called, the last line is |
| 78 | + popped and the entire code is re-evaluated. As you can |
| 79 | + imagine, this has a lot of potential problems, but for |
| 80 | + defining classes and functions, I've found it to be |
| 81 | + nothing but useful. |
| 82 | + |
| 83 | +* Pastebin code/write to file. |
| 84 | + I don't really use the save thing much, but the pastebin |
| 85 | + thing's great. Hit a key and what you see on the screen |
| 86 | + will be sent to a pastebin and a URL is returned for you |
| 87 | + to do what you like with. I've hardcoded rafb.net/paste |
| 88 | + in for now, that needs to be fixed so it's configurable. |
| 89 | + Next release, I promise. |
| 90 | + |
| 91 | +* Flush curses screen to stdout. |
| 92 | + A featurette, perhaps, but I thought it was worth noting. |
| 93 | + I can't personally recall a curses app that does this, |
| 94 | + perhaps it's often not useful, but when you quit bpython, |
| 95 | + the screen data will be flushed to stdout, so it basically |
| 96 | + looks the same as if you had quit the vanilla interpreter. |
| 97 | + |
| 98 | +Known Bugs |
| 99 | +========== |
| 100 | + |
| 101 | +* There's some weirdness when you use rewind sometimes with how |
| 102 | +it displays the text afterwards, I haven't had enough time to |
| 103 | +sit down and look at exactly what's causing it, as it doesn't |
| 104 | +seem to happen a lot, and it fixes itself pretty quickly anyway. |
| 105 | + |
| 106 | +* Triple quoted strings over multiple lines work, but they're |
| 107 | +not highlighted properly. |
| 108 | + |
| 109 | +* There is no way to configure the keys or the pastebin options, |
| 110 | +this is a definite for the next release. |
0 commit comments