'Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions.  (For class
instances, class members are also considered.)
WARNING: this can still invoke arbitrary C code, if an object
with a __getattr__ hook is evaluated.'

def attr_matches(self, text):

    import re
    bsw = '[a-zA-Z0-9_\\(\\)\\[\\]"\']'
    m = re.match('(\\w+(\\.\\w+)*)\\.(\\w*)'.replace('\\w', bsw), text)
    if (not m):
        return []
    (expr, attr) = m.group(1, 3)
    try:
        try:
            thisobject = eval(expr, self.global_ns, self.local_ns)
        except NameError as e:
            '\n                                                                print    str(e)\n                                                                try:\n                                                                                exec    "import    %s"%expr    in    global_ns,    self.local_ns\n                                                                                thisobject    =    eval(expr,    global_ns,    self.local_ns)\n                                                                except    ImportError:\n                                                                                pass\n                                                                '
    except Exception as e:
        return []
    words = dir(thisobject)
    if ('__builtins__' in words):
        words.remove('__builtins__')
    if hasattr(thisobject, '__class__'):
        words.append('__class__')
        words.extend(get_class_members(thisobject.__class__))
    words = [x for x in words if (not x.startswith('__'))]
    matches = []
    n = len(attr)
    for word in words:
        if ((word[:n] == attr) and hasattr(thisobject, word)):
            val = getattr(thisobject, word)
            word = self._callable_postfix(val, ('%s.%s' % (expr, word)))
            matches.append(word)
    return matches
