diff -r 917295aaad76 Lib/cmd.py --- a/Lib/cmd.py Mon Jul 30 00:01:44 2012 +0200 +++ b/Lib/cmd.py Sun Jul 29 23:16:25 2012 -0400 @@ -279,9 +279,27 @@ 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 list(filter(filter_fn, dir(self))) + def complete_help(self, *args): commands = set(self.completenames(*args))