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

Function _safe_getattr

IPython/lib/pretty.py:102–111  ·  view source on GitHub ↗

Safe version of getattr. Same as getattr, but will return ``default`` on any Exception, rather than raising.

(obj, attr, default=None)

Source from the content-addressed store, hash-verified

100_re_pattern_type = type(re.compile(''))
101
102def _safe_getattr(obj, attr, default=None):
103 """Safe version of getattr.
104
105 Same as getattr, but will return ``default`` on any Exception,
106 rather than raising.
107 """
108 try:
109 return getattr(obj, attr, default)
110 except Exception:
111 return default
112
113@undoc
114class CUnicodeIO(StringIO):

Callers 5

prettyMethod · 0.85
_in_deferred_typesMethod · 0.85
_default_pprintFunction · 0.85
_type_pprintFunction · 0.85
_function_pprintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected