diff options
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r-- | Lib/rlcompleter.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 10a53dc..2739fed 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -86,6 +86,11 @@ class Completer: except IndexError: return None + def _callable_postfix(self, val, word): + if callable(val): + word = word + "(" + return word + def global_matches(self, text): """Compute matches when text is a simple name. @@ -96,12 +101,13 @@ class Completer: import keyword matches = [] n = len(text) - for list in [keyword.kwlist, - builtins.__dict__, - self.namespace]: - for word in list: - if word[:n] == text and word != "__builtins__": - matches.append(word) + for word in keyword.kwlist: + if word[:n] == text: + matches.append(word) + for nspace in [builtins.__dict__, self.namespace]: + for word, val in nspace.items(): + if word[:n] == text and word != "builtins": + matches.append(self._callable_postfix(val, word)) return matches def attr_matches(self, text): @@ -133,7 +139,9 @@ class Completer: n = len(attr) for word in words: if word[:n] == attr and word != "__builtins__": - matches.append("%s.%s" % (expr, word)) + val = getattr(object, word) + word = self._callable_postfix(val, "%s.%s" % (expr, word)) + matches.append(word) return matches def get_class_members(klass): |