[Tutor] Python with readline

Erik Price erikprice@mac.com
Tue, 16 Apr 2002 20:42:01 -0400


A few weeks back I asked about how I could get some of the emacs-style 
functionality (command history, emacs navigation keybindings) into my 
Python 2.2 interactive interpreter.  Someone (I forget) said that this 
is GNU Readline, and that I should look into recompiling with readline.

Well, I've tried a few different iterations of it -- by slightly 
changing the Modules/Setup file in the source tree from my Python 2.2 
tarball.  Unfortunately, I can't seem to get the right combination of 
flags.  Here is the text of the section where I'm supposed to turn it on:

<snip>
# GNU readline.  Unlike previous Python incarnations, GNU readline is
# now incorporated in an optional module, configured in the Setup file
# instead of by a configure script switch.  You may have to insert a
# -L option pointing to the directory where libreadline.* lives,
# and you may have to change -ltermcap to -ltermlib or perhaps remove
# it, depending on your system -- see the GNU readline instructions.
# It's okay for this to be a shared library, too.

#readline readline.c -lreadline -ltermcap
</snip>

I've tried simply uncommenting the line, adding the -L option in various 
places on the line, specifying a path to my readline library, etc, but I 
haven't had success -- either the ./configure has failed, the make has 
failed, or I've ended up with a Python with no readline ability -- 
exactly what I have now.

Does anyone have any familiarity with setting Python up for this?  I'm 
using Mac OS X 10.1.3, but I can't imagine that the procedure is much 
different than for Linux or any other Unix.  I'm not really clear on 
what readline does, I imagine it's some kind of library, but my lack of 
familiarity with C and the whole "make" business is probably making this 
difficult for me to grasp.

I've asked about this on comp.lang.python, but not persistently.  Before 
I pester them again, I thought I'd ask here.  It's not an emergency -- I 
can get by without it -- but now that emacs-style keybindings work in 
almost every Mac OS X app, I find myself constantly hitting Ctrl-F or 
Ctrl-P, and in the interactive interpreter this just gives me garbage 
escape characters.

Thanks in advance,


Erik