MCPcopy Create free account
hub / github.com/ipython/ipython / get_keys

Method get_keys

IPython/core/completer.py:1568–1585  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

1566 def dict_key_matches(self, text):
1567 "Match string keys in a dictionary, after e.g. 'foo[' "
1568 def get_keys(obj):
1569 # Objects can define their own completions by defining an
1570 # _ipy_key_completions_() method.
1571 method = get_real_method(obj, '_ipython_key_completions_')
1572 if method is not None:
1573 return method()
1574
1575 # Special case some common in-memory dict-like types
1576 if isinstance(obj, dict) or\
1577 _safe_isinstance(obj, 'pandas', 'DataFrame'):
1578 try:
1579 return list(obj.keys())
1580 except Exception:
1581 return []
1582 elif _safe_isinstance(obj, 'numpy', 'ndarray') or\
1583 _safe_isinstance(obj, 'numpy', 'void'):
1584 return obj.dtype.names or []
1585 return []
1586
1587 try:
1588 regexps = self.__dict_key_regexps

Callers

nothing calls this directly

Calls 2

get_real_methodFunction · 0.90
_safe_isinstanceFunction · 0.85

Tested by

no test coverage detected