##// END OF EJS Templates
Close http://www.scipy.net/roundup/ipython/issue34 with slightly modified...
fperez -
r3:22db71d2
parent child Browse files
Show More
@@ -84,6 +84,13 b' import __main__'
84 84
85 85 __all__ = ["Completer"]
86 86
87 # declares Python 2.2 compatibility symbols:
88 try:
89 basestring
90 except NameError:
91 import types
92 basestring = (types.StringType, types.UnicodeType)
93
87 94 class Completer:
88 95 def __init__(self, namespace = None):
89 96 """Create a new completer for the command line.
@@ -171,21 +178,15 b' class Completer:'
171 178 return []
172 179 expr, attr = m.group(1, 3)
173 180 object = eval(expr, self.namespace)
174 words = dir(object)
181 words = [w for w in dir(object) if isinstance(w, basestring)]
175 182 if hasattr(object,'__class__'):
176 183 words.append('__class__')
177 184 words.extend(get_class_members(object.__class__))
178 185 n = len(attr)
179 186 matches = []
180 187 for word in words:
181 try:
182 188 if word[:n] == attr and word != "__builtins__":
183 189 matches.append("%s.%s" % (expr, word))
184 except:
185 # some badly behaved objects pollute dir() with non-strings,
186 # which cause the completion to fail. This way we skip the
187 # bad entries and can still continue processing the others.
188 pass
189 190 return matches
190 191
191 192 def get_class_members(klass):
General Comments 0
You need to be logged in to leave comments. Login now