Tab completion

Chris Rebert clp2 at
Thu Apr 2 17:31:39 CEST 2009

On Thu, Apr 2, 2009 at 7:59 AM, Steven D'Aprano
<steve at> wrote:
> Does anyone use the tab-completion recipe in the docs?
> 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?

You could write a ~/.inputrc to change the bindings.


I have a blog:

More information about the Python-list mailing list