Welcome, guest | Sign In | My Account | Store | Cart
"""Indentable rlcompleter

Extend standard rlcompleter module to let tab key can indent
and also completing valid Python identifiers and keywords."""

import readline,rlcompleter

class irlcompleter(rlcompleter.Completer):
        def complete(self, text, state):
                if text == "":
                        #you could  replace \t to 4 or 8 spaces if you prefer indent via spaces
                        return ['\t',None][state]
                        return rlcompleter.Completer.complete(self,text,state)

#you could change this line to bind another key instead tab.
readline.parse_and_bind("tab: complete")


  • revision 3 (17 years ago)
  • previous revisions are not available