python - CMD auto-completion not working correctly -
(python 3.3.4)
i using cmd module build application, reason can't completion work correctly. whenever hit tab
indents input string!!
so, if have this: (myshell)>> ta«cursor here»
hit «tab» , this: (myshell)>> ta «cursor here»
i have tried in idle, windows power shell , in python interpreter itself, guess... neither completion of commands nor completion of arguments work!!
the code this:
class myshell(cmd.cmd): def __init__(self): cmd.cmd.__init__(self) self.intro = "welcome myshell test.\npowered rodrigo serrĂ£o" self.prompt = "(myshell)>>" def do_talk(self, text): print("hello") stuff = ["blabla", "bananas!", "noodles"] def complete_talk(self, text, line, s, e): if text: return [i in stuff if i.startswith(text)] else: return stuff myshell().cmdloop()
i have read questions this, including one: python cmd tab completion problems
and may have readline
thing. tried import it, apparently don't have it.
so i'm writing interactive shell app on python too, auto completion working, install pyreadline, readline module unix specific.
if don't know how install execute following line:
pip install pyreadline
Comments
Post a Comment