Show More
@@ -185,21 +185,29 b' class Completer:' | |||
|
185 | 185 | |
|
186 | 186 | if not m: |
|
187 | 187 | return [] |
|
188 | ||
|
188 | 189 | expr, attr = m.group(1, 3) |
|
189 | 190 | try: |
|
190 | 191 | object = eval(expr, self.namespace) |
|
191 | 192 | except: |
|
192 | 193 | object = eval(expr, self.global_namespace) |
|
193 | words = [w for w in dir(object) if isinstance(w, basestring)] | |
|
194 | ||
|
195 | # for modules which define __all__, complete only on those. | |
|
196 | if type(object) == types.ModuleType and hasattr(object, '__all__'): | |
|
197 | words = getattr(object, '__all__') | |
|
198 | else: | |
|
199 | words = dir(object) | |
|
194 | 200 | if hasattr(object,'__class__'): |
|
195 | 201 | words.append('__class__') |
|
196 | 202 | words.extend(get_class_members(object.__class__)) |
|
203 | ||
|
204 | # filter out non-string attributes which may be stuffed by dir() calls | |
|
205 | # and poor coding in third-party modules | |
|
206 | words = [w for w in words | |
|
207 | if isinstance(w, basestring) and w != "__builtins__"] | |
|
208 | # Build match list to return | |
|
197 | 209 | n = len(attr) |
|
198 | matches = [] | |
|
199 | for word in words: | |
|
200 | if word[:n] == attr and word != "__builtins__": | |
|
201 | matches.append("%s.%s" % (expr, word)) | |
|
202 | return matches | |
|
210 | return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ] | |
|
203 | 211 | |
|
204 | 212 | class IPCompleter(Completer): |
|
205 | 213 | """Extension of the completer class with IPython-specific features""" |
@@ -1,5 +1,10 b'' | |||
|
1 | 1 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 2 | |
|
3 | * IPython/completer.py (Completer.attr_matches): for modules which | |
|
4 | define __all__, complete only on those. After a patch by Jeffrey | |
|
5 | Collins <jcollins-AT-boulder.net>. Also, clean up and speed up | |
|
6 | this routine. | |
|
7 | ||
|
3 | 8 | * IPython/Logger.py (Logger.log): fix a history handling bug. I |
|
4 | 9 | don't know if this is the end of it, but the behavior now is |
|
5 | 10 | certainly much more correct. Note that coupled with macros, |
General Comments 0
You need to be logged in to leave comments.
Login now