Tab completion

Steven D'Aprano steve at
Thu Apr 2 16:59:29 CEST 2009

Does anyone use the tab-completion recipe in the docs?

suggests using this to enable tab-completion:

    import readline
except ImportError:
    print "Module readline not available."
    import rlcompleter
    readline.parse_and_bind("tab: complete")

which is all very nice, but it makes it rather difficult to indent code 

>>> 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?


More information about the Python-list mailing list