def _GetAttr(obj, attr, default_value):
  """Gets a specified attribute of an object (if exist).

  Args:
    obj: Object.
    attr: Attribute name (string).
    default_value: Default value to return if object does not have attribute
      specified.

  Returns:
    Specified attribute value if exists, else default value.
  """
  if hasattr(obj, attr):
    return obj.__getattribute__(attr)
  else:
    return default_value