GNU readline module
mwh21 at cam.ac.uk
Sun Nov 14 05:16:05 EST 1999
kvijayan at calum.csclub.uwaterloo.ca (Kannan Vijayan) writes:
> I'm trying to get the readline module
> to work in python.
> I have an app to which I want to add
> tab-completion of commands and other things.
> The docs for the GNU readline module are
> extremely sparse.
> Most of what I know about the module are derived from looking at
> it's source, looking at how "rlcompleter" uses it, and my own sparse
> knowledge of the C readline implementation itself.
I've generally been able to make it do what I want. Not always easily
(exceptions getting binned can be really confusing).
> As far as I can see, there is no hook to the
> "readline(char *PROMPT)" function in the
> readline module. Am I missing something?
That's raw_input, more or less.
> I have, however, gotten my completer function
> to work well from within the interactive
> interpreter environment. What I'm having
> trouble with is getting it to work from a
> non-interactively interpreted application in
> it's own happy .py file. I assume there would
> be some function which I could call to read a
> line, which in turn would call my completer
> function to do the job when a tab is pressed.
Are you aware that to activate readline away from the interactive
interpreter you have to import readline explicitly? Chuck an
at the top of your main script and give it another go.
> I have a nagging notion that maybe the readline
> module is only for use from withing the
> interactive interpreter. IS this true? if so..
> that's extremely dissapointing.
I've never seen it used for anything else. There's no particular
reason for this. I don't know whether it's inclusion was motivated by
enhancing the interactive environment or allowing it's use it other
applications. Any PyHistorians care to comment?
More information about the Python-list