diff options
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r-- | Lib/rlcompleter.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index be8aee0..d368876 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -106,6 +106,12 @@ class Completer: n = len(text) for word in keyword.kwlist: if word[:n] == text: + if word in {'finally', 'try'}: + word = word + ':' + elif word not in {'False', 'None', 'True', + 'break', 'continue', 'pass', + 'else'}: + word = word + ' ' matches.append(word) for nspace in [builtins.__dict__, self.namespace]: for word, val in nspace.items(): @@ -144,14 +150,28 @@ class Completer: words.update(get_class_members(thisobject.__class__)) matches = [] n = len(attr) - for word in words: - if word[:n] == attr: - try: - val = getattr(thisobject, word) - except Exception: - continue # Exclude properties that are not set - word = self._callable_postfix(val, "%s.%s" % (expr, word)) - matches.append(word) + if attr == '': + noprefix = '_' + elif attr == '_': + noprefix = '__' + else: + noprefix = None + while True: + for word in words: + if (word[:n] == attr and + not (noprefix and word[:n+1] == noprefix)): + try: + val = getattr(thisobject, word) + except Exception: + continue # Exclude properties that are not set + word = self._callable_postfix(val, "%s.%s" % (expr, word)) + matches.append(word) + if matches or not noprefix: + break + if noprefix == '_': + noprefix = '__' + else: + noprefix = None matches.sort() return matches |