Rajashree Thorat wrote: > Please can anyone help me in resolving following problem. > > import cmd > class CmdLineApp(cmd.Cmd): > > def do_grep(self, line): > print line > > option = ["--ignore-case", > "--invert-match","--word-regexp","--line-regexp"] > def complete_grep(self, text, line, begidx, endidx): > return [i for i in CmdLineApp.option if > i.startswith(text)] > > interpreter = CmdLineApp() > interpreter.cmdloop() > > In above program I want to do command line completion (or tab completion). > If the elements of option list starts with special character such as > '-', '@', '#', '--' , then it is giving me output like > > (Cmd) grep > grep > (Cmd) grep ------ > > instead of > > (Cmd) grep -- > --ignore-case --invert-match --word-regexp --line-regexp > > How I can handle this special characters?
Try removing them from readline's set of delimiters with import readline delims = readline.get_completer_delims() my_delims = "".join(set(delims) - set("-@#")) readline.set_completer_delims(my_delims) -- http://mail.python.org/mailman/listinfo/python-list