code: def safe_getattr(obj, name, default=_sentinel):
      try:
          attr, is_get_descriptor = getattr_static(obj, name)
      except AttributeError:
          if default is _sentinel:
              raise
          return default
      else:
          if type(attr) in ALLOWED_DESCRIPTOR_ACCESS:
              # In case of descriptors that have get methods we cannot return
              # it's value, because that would mean code execution.
              return getattr(obj, name)
      return attr
  
imports: import inspect
  import types
  import sys
  from textwrap import dedent
  import operator
  from collections import namedtuple
  from jedi._compatibility import unicode, is_py3, builtins, py_version, force_unicode, print_to_stderr
  from jedi.evaluate.compiled.getattr_static import getattr_static
label_desc: Use image node_id 2 for calling a global function with example usage: safe_getattr(obj, name, default) and returns: attr, default, getattr