(obj1, obj2, attributes)
return True
Compare two objects attributes
Compare two objects attributes
Compare two objects attributes
def equal_attributes(obj1, obj2, attributes):
    """Compare two objects attributes"""
    # not attributes given return False by default
    if not attributes:
        return False

    temp1, temp2 = object(), object()
    for attr in attributes:
        # support callables like itemgetter
        if callable(attr):
            if attr(obj1) != attr(obj2):
                return False
        elif getattr(obj1, attr, temp1) != getattr(obj2, attr, temp2):
            return False
    # all attributes equal
    return True
def equal_attributes ( obj1 , obj2 , attributes ) : # not attributes given return False by default if not attributes : return False temp1 , temp2 = object ( ) , object ( ) for attr in attributes : # support callables like itemgetter if callable ( attr ) : if attr ( obj1 ) != attr ( obj2 ) : return False elif getattr ( obj1 , attr , temp1 ) != getattr ( obj2 , attr , temp2 ) : return False # all attributes equal return True