[Python-Dev] readline module seems crippled - am I missing something?

Skip Montanaro skip@mojam.com (Skip Montanaro)
Sat, 6 Jan 2001 22:05:22 -0600 (CST)

For a more-or-less throwaway script I'm working on I need a little input
function similar to Emacs's read-from-minibuffer, which accepts both a
prompt and an initial string for the input buffer.  Seems like I ought to be
able to whip something up using readline, but it's not happening.  GNU
readline's docs aren't the greatest, but I thought this simple script would

    import readline
    x = raw_input("?")
    print x

I expected to see an editable "default" displayed after the prompt and have
x default to "default" if I just hit the return key.  I see nothing
displayed after the question mark, and x is the empty string if I just hit

This does print "default":

    x = readline.get_line_buffer()
    print x

so I know that insert_text and get_line_buffer seem to be working as
intended.  Looking at call_readline in Modules/readline.c I see nothing that
would disrupt the line buffer before the call to readline().

Am I missing something totally obvious about how GNU readline works or the
conditions under which readline is used (only at the interactive prompt?) or
is some required bit of GNU readline not exposed through Python's readline