Confusion regarding the readline module

Diez B. Roggisch deets at nospam.web.de
Tue May 6 06:22:38 EDT 2008


Siddhant wrote:

> Hi!
> I am having some doubts related to the readline module. I hope someone
> could clear them.
> 1. What exactly does the readline.get_line_buffer() function do? Does
> it return whatever is the current input by the user? If yes, then can
> I use it to check the current inputs of the user and base the next-
> word completion against whatever the user has entered so far? There
> wasn't much documentation on it, and a lot of googling couldn't help
> much. :(
> 2. Related to the completer function, what is meant by returning the
> "state"th completion for "text"? Is the completer function called
> everytime (for all possible values of "state") when I press the Tab
> key? When/How is it called?
> 
> Basically, I need to define a completer function, that should take
> into consideration whatever the user has entered so far, and complete
> the next word accordingly. The same way as a "cd /some/file" is
> meaningless.

I don't know anything about readline (beyond it's existence of course) - but
I do know & use the rlcompleter2 module. Go download it and look into it's
source, it should give you an idea how to proceed.

Diez



More information about the Python-list mailing list