summaryrefslogtreecommitdiff
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py38
1 files changed, 30 insertions, 8 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 401a626179..bca4a7bc52 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -113,6 +113,12 @@ class Completer:
for word in keyword.kwlist:
if word[:n] == text:
seen.add(word)
+ 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 [self.namespace, builtins.__dict__]:
for word, val in nspace.items():
@@ -152,14 +158,30 @@ 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)):
+ match = "%s.%s" % (expr, word)
+ try:
+ val = getattr(thisobject, word)
+ except Exception:
+ pass # Include even if attribute not set
+ else:
+ match = self._callable_postfix(val, match)
+ matches.append(match)
+ if matches or not noprefix:
+ break
+ if noprefix == '_':
+ noprefix = '__'
+ else:
+ noprefix = None
matches.sort()
return matches