pyEdlin

pyEdlin implements an edlin-style line editor, allowing you to edit any list-like buffer a line at a time.

I have often found myself attempting to prototype a method or class at the interactive python interpreter. While this works for simple methods or classes, I frequently find myself needing to make a change to some portion of what I have already entered.

Unable to find any tools that fit what I was trying to accomplish, I decided to create an interactive line editor that could run python code. edlin isn't terribly complex, so I figured it would be a good place to start.

Using pyEdlin is fairly straight-forward, and generally follows this pattern:

>>> import edlin
>>> ed = edlin.edlin()
>>> ed.edlin()
*

The asterisk ('*') is pyEdlin's prompt, just like in edlin.

To begin typing code, use the Append command, 'a':

*a
1:*for ent in dir(module):
2:* s += '\|' + ent
3:*
4:*^Z

Oops, I didn't initially define the variable s as an empty string.
No biggy, I just insert it at the beginning.

*1i
1:*s = ''
2:*^Z
*l
1: s = ''
2:*for ent in dir(module):
3: s += '\|' + ent
4:
*

There are a few caveats you should be aware of.

  • Just like at the interactive prompt, extra vertical white-space is a no-no. Placing an extra line in a class or method definition will make the interpreter think that you are finished, and you will likely get an error. Of course, this won't actually happen until you run your code -- nothing will happen while you are entering it.

pyEdlin is an open-source project released under a BSD-style license. As it is currently implemented in pure Python, it should be fairly cross-platform. It has only been tested, however, on Windows XP and FreeBSD 4.8.

As far as legal issues goes, edlin is Copyright © Microsoft Corporation, I believe. This implementation was done as a 'clean-room' reverse-engineer, by observing how edlin operates and mimicking it's behavior.

Copyright © 2004, 2005 Timothy J. Warren
All Rights Reserved.