summaryrefslogtreecommitdiff
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-01-06 18:02:16 +0000
committerGeorg Brandl <georg@python.org>2010-01-06 18:02:16 +0000
commit89040530035ee9a8d0b5ae34c6e73b80fafa4307 (patch)
tree1fe0036448828f6d1f2a2f92323828eaa2fb136f /Lib/cmd.py
parent5089a38af2b90dfe51bbf157ff38227c85eff687 (diff)
downloadcpython-git-89040530035ee9a8d0b5ae34c6e73b80fafa4307.tar.gz
#5991: let completion for the "help" command include help topics.
This also simplifies the Cmd.get_names() method implementation; it was written at a time where dir() didn't consider base class attributes.
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 3f82b48710..5847f76360 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -281,19 +281,15 @@ class Cmd:
return None
def get_names(self):
- # Inheritance says we have to look in class and
- # base classes; order is not important.
- names = []
- classes = [self.__class__]
- while classes:
- aclass = classes.pop(0)
- if aclass.__bases__:
- classes = classes + list(aclass.__bases__)
- names = names + dir(aclass)
- return names
+ # This method used to pull in base class attributes
+ # at a time dir() didn't do it yet.
+ return dir(self.__class__)
def complete_help(self, *args):
- return self.completenames(*args)
+ commands = set(self.completenames(*args))
+ topics = set(a[5:] for a in self.get_names()
+ if a.startswith('help_' + args[0]))
+ return list(commands | topics)
def do_help(self, arg):
if arg: