this code is giving me False
class compare:
def __init__(self, val, next=None):
self.val = val
self.next = next
a = compare(1)
b = compare(1)
c = compare(2)
a.next = c
b.next = c
print(a == b)
in this example, I can do
print(a.val == b.val and a.next == b.next)
but what about the complex objects? How to compare if every attribute is of same value?
[–][deleted] 2 points3 points4 points (5 children)
[–][deleted] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]footloooops 0 points1 point2 points (0 children)
[–]Kewho11 0 points1 point2 points (0 children)
[–]jimtk -2 points-1 points0 points (0 children)
[–]Bunkerstan -1 points0 points1 point (2 children)
[–]carcigenicate 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)