Мой текущий подход - это пройти через список 1, а затем пройти через список 2.
Код: Выделить всё
def objectListsNotEqual(list_1, list_2):
if(len(list_1) != len(list_2)):
return True
# same length lists, so check it
for obj_1 in list_1:
if(not(any(obj_1.equals(obj_2) for obj_2 in list_2))):
return True
for obj_2 in list_2:
if(not(any(obj_2.equals(obj_1) for obj_1 in list_1))):
return True
# if execution reaches here, then both lists match
return False
Код: Выделить всё
list_1 = [obj_1(foo), obj_2(foo), obj_3(bar)]
list_2 = [obj_4(foo), obj_5(bar), obj_6(bar)]
objectListsNotEqual(list_1, list_2) # --> returns False due to the use of any() function
Подробнее здесь: https://stackoverflow.com/questions/795 ... -in-python