By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,846 Members | 1,862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,846 IT Pros & Developers. It's quick & easy.

readline, rlcompleter

P: n/a
This a case where the documentation is lacking. The standard library
documentation
(http://www.python.org/dev/doc/devel/...completer.html) gives
this example
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")

but I don't find a list of recognized key bindings. For instance, can I
would
like to bind shift-tab to rlcompleter, is that possible? Can I use
function
keys? I did various attempt, but I did not succed :-(
Is there any readline-guru here with some good pointers?
Michele Simionato

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mi***************@gmail.com writes:
This a case where the documentation is lacking. The standard library
documentation
(http://www.python.org/dev/doc/devel/...completer.html) gives
this example
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")

but I don't find a list of recognized key bindings. For instance, can I
would
like to bind shift-tab to rlcompleter, is that possible? Can I use
function
keys? I did various attempt, but I did not succed :-(
Is there any readline-guru here with some good pointers?
Michele Simionato


Basically, you could use any key sequence that is sent to the terminal. So
shift-tab is out (that's not sent as a key to any terminal program).

Function keys would have to be specified as the key sequence sent by a
function key ("\e[11~" for F1, for instance).

Have a look at the readline info page, or the man page. The syntax of
readline.parse_and_bind is the same as that of an inputrc file.

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
Jul 18 '05 #2

P: n/a
There is a pretty complete (no pun intended) example in the standard
cmd module

<http://docs.python.org/lib/module-cmd.html>

Check file cmd.py in your Python installation .../lib/pythonX.Y/cmd.py,
specifically the methods Cmd.preloop() and Cmd.complete().

Another, more elaborate example is in PySH at

<http://unixnaut.com/skills/Languages/python/pysh.py>
/Jean Brouwers

PS) A version of readline for Windows is here

<http://newcenturycomputers.net/projects/readline.html>

mi***************@gmail.com wrote:
This a case where the documentation is lacking. The standard library
documentation
(http://www.python.org/dev/doc/devel/...completer.html) gives this example
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")

but I don't find a list of recognized key bindings. For instance, can I would like to bind shift-tab to rlcompleter, is that possible? Can I use function keys? I did various attempt, but I did not succed :-(
Is there any readline-guru here with some good pointers?
Michele Simionato


Jul 18 '05 #3

P: n/a
Hi Michele,
readline.parse_and_bind("tab: complete")

but I don't find a list of recognized key bindings.


The python readline module just wraps the GNU Readline Library, so you
need to check the manuals of the latter. It's not that much text and
you'll find the information needed at:

http://cnswww.cns.cwru.edu/php/chet/...man.html#SEC10

Yours,

Mark
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.