diff -r a3e48273dce3 Lib/cmd.py --- a/Lib/cmd.py Tue Oct 18 17:16:00 2011 +0200 +++ b/Lib/cmd.py Thu Oct 20 22:34:32 2011 -0700 @@ -281,9 +281,26 @@ return None def get_names(self): - # This method used to pull in base class attributes - # at a time dir() didn't do it yet. - return dir(self.__class__) + """Get completion candidates for commands and help topics. + + By default this method returns all 'do_' prefixed methods as command + completion candidates, and all 'help_' prefixed methods as help topic + candidates. + + :Returns: a list of zero or more valid command / help completions. + """ + + filter_fn = lambda name: ((name.startswith('do_') or + name.startswith('help_')) and + not name.endswith('EOF')) + + # NOTE: use dir(self) so one can get all of the dynamic attributes + # associated with a given class, as dir(self.__class__) lists all of + # the static members defined in the class defintion. + + # XXX: this really shouldn't have to be recalculated all the time as + # most classes remain static. + return filter(filter_fn, dir(self)) def complete_help(self, *args): commands = set(self.completenames(*args))