def had_to_set_new_value(obj, attr_name, new_value):
    """Return whether had to set new value for attr.

    That is, if the given value is different than the
    one stored on the

    If the attribute didn't previously exist, we also
    consider this case as a case where the value changed.
    We also set the attribute to the new value, if it
    changed.
    """
    ### check whether the attribute existed previously,
    ### considering the value as the current one
    try:
        current_value = getattr(obj, attr_name)

    ### if there's no current value, we just pass, since
    ### we'll be creating the attribute in the next step
    except AttributeError:
        pass

    ### if there is a current value, though, we check
    ### whether such value is equal to the new one,
    ### in which case we just return False to indicate
    ### we didn't need to set the attribute ourselves

    else:
        if current_value == new_value:
            return False

    ### if we get to this point in the function, than
    ### the attribute either didn't exist or it's value
    ### is different than the new one provided, meaning
    ### we need to set it to the new value
    setattr(obj, attr_name, new_value)

    ### we finally return True to indicate we had to set
    ### the value
    return True
Return whether had to set new value for attr.

    That is, if the given value is different than the
    one stored on the

    If the attribute didn't previously exist, we also
    consider this case as a case where the value changed.
    We also set the attribute to the new value, if it
    changed.
    
nodezator/ourstdlibs/behaviour.py