|
> those only apply to arrays of primitives I guess you've not written much python, or just not used any custom types in lists if you have. class Thing:
def __init__(self, a, b):
self.a = a; self.b = b
def __eq__(me, them):
return me.a == them.a and me.b == them.b
>>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hi")]
True
>>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hello")]
False
In this case, the builtins are syntax, namely the `==` operator. There's a uniform syntax for comparing two objects for equality. |