code: def call_on_if_def(obj, attr_name, callable, default, *args, **kwargs):
      
      try:
          attr = getattr(obj, attr_name)
      except AttributeError:
          return default
      else:
          return callable(attr, *args, **kwargs)
docs: Calls the provided callable on the provided attribute of ``obj`` if it is defined.
  
      If not, returns default.