0
__ne__ and __eq__
What does it mean? "If __ne__ is not satisfied, the value opposite to __eq__ is returned."
3 Respostas
+ 6
class eq:
def __init__(self, num):
self.num = num
def __eq__(self, other):
return self.num * other.num == 20
a = b = eq(4)
print(a != b) #True
a = eq(4)
b = eq(5)
print(a != b) #False
0
This seems to mean, that if you didn't overload the != operator, it executes your __eq__ code and tries to invert it. I don't know which way.
0
How can I overload != ?