def complete_names(word, namespace):
"""Complete variable names or attributes
:param word: word to be completed
:type word: str
:param namespace: namespace
:type namespace: dict
:returns: completion matches
:rtype: list of str
>>> complete_names('fo', {'foo': 'bar'})
['foo', 'for', 'format(']
"""
# start completer
completer = rlcompleter.Completer(namespace)
# find matches with std library (don't try to implement this yourself)
completer.complete(word, 0)
return sorted(set(completer.matches))
评论列表
文章目录