Tab completion

Chris Jones cjns1989 at gmail.com
Thu Apr 2 19:33:53 CEST 2009


On Thu, Apr 02, 2009 at 10:59:29AM EDT, Steven D'Aprano wrote:
> Does anyone use the tab-completion recipe in the docs?
> 
> http://docs.python.org/library/rlcompleter.html#module-rlcompleter
> 
> suggests using this to enable tab-completion:
> 
> try:
>     import readline
> except ImportError:
>     print "Module readline not available."
> else:
>     import rlcompleter
>     readline.parse_and_bind("tab: complete")
> 
> which is all very nice, but it makes it rather difficult to indent code 
> blocks:
> 
> >>> def func(x):
> ...
> Display all 174 possibilities? (y or n)
> 
> 
> I like tab-completion, but I'd rather not be reduced to typing spaces for 
> indents in the interpreter. What do other people do?
> 
> Can I bind Ctrl-tab to the completion instead of regular tab? I tried 
> readline.parse_and_bind("C-tab: complete") but it still completes on 
> regular tab.
> 
> The GNU readline library claims that M-tab (which I guess is Alt-tab) 
> will enter a tab character. Problem is that Alt-tab is intercepted by my 
> window manager for something else.
> 
> Any other suggestions or hints?

CTRL+V <TAB>



More information about the Python-list mailing list