<home> <personal> <hacks> <links> <quotes> <details> <summaries>

~mwh/hacks: <bytecodehacks> <xmms-py> <pyicqlib> <pyrepl>

pyrepl

For ages now, I've been working on and off on a replacement for readline for use from Python. readline is undoubtedly great, but a couple of things irritate me about it. One is the inability to do sane multi-line editing. Have you ever typed something like:

>>> for i in range(10):
...     for i in range(10):
...         print i*j

into a Python top-level? Grr, that "i" on the second line should have been a "j". Wouldn't it be nice if you could just press "up" on your keyboard and fix it? This was one of the aims I kept in mind when writing pyrepl (or pyrl as I used to call it, but that name's taken).

Another irritation of readline is the GPL. I'm not even nearly as anti-GPL as some, but I don't want to have to GPL my program just so I can use readline.

0.7 adds to the version that runs an a terminal an experimental version that runs in a pygame surface. A long term goal is Mathematica-like notebooks, but that's a loong way off...

Anyway, after many months of intermittent toil I present:

pyrepl 0.7.2

(0.7.2 fixes a number of silly small typos and slips)

(the significant change since 0.7 is inclusion of a working setup.py...)

For more details on the changes since 0.6, you can read the CHANGES file.

NEWS (as of Dec 12 2002): pyrepl now has dedicated mailing lists where discussion about pyrepl's development will take place.

Dependencies: Python 2.1 with the termios and curses modules built (I don't really use curses, but I need the terminfo functions that live in the curses module), or pygame installed (if you want to live on the bleeding edge).

There are probably portability gremlins in some of the ioctl using code. Fixes gratefully received!

Features:

pyrepl currently consists of four major classes:

Reader <- HistoricalReader <- CompletingReader <- PythonReader

There's also a UnixConsole class that handles the low-level details.

Each of these lives in it's own file, and there are a bunch of support files (including a C module that just provides a bit of a speed up - building it is strictly optional).

IMHO, the best way to get a feel for how it works is to type

$ python pythoni

and just play around. If you're used to readline's emacs-mode, you should feel right at home. One point that might confuse: because the arrow keys are used to move up and down in the command currently being edited, you need to use ^P and ^N to move through the history.

<home> <personal> <hacks> <links> <quotes> <details> <summaries>

Valid XHTML 1.0! Valid CSS! Last updated: $Date: 2002/12/12 11:52:29 $. Comments to mwh@python.net.
Best viewed with any browser. Except netscape 4 with javascript on...