def setdefaultattrs(obj, attrs):
    """
     Sets the attributes in attr if they are not contained in obj.

    :param obj:     the object to check
    :param attrs:   a dict containing attributes to check as key and a default
                    value as value.
    :return:        a copy of the object containing the default values for
                    missing attributes
    """
    for key in attrs.keys():
        if hasattr(obj, key):
            print('obj {} has {} ({})'.format(obj, key, getattr(obj, key)))
        else:
            print("obj {} doesn't have {} (default={})".format(obj, key,
                attrs[key]))
            setattr(obj, key, attrs[key])
