def set_dict(obj, d):
    """Set the :attr:`object.__dict__` of `obj`.

    :param obj: input object.
    :param d: dictionary.
    :return: the modified object."""
    if d:
        obj.__dict__ = d
    return obj