0

__ne__ and __eq__

What does it mean? "If __ne__ is not satisfied, the value opposite to __eq__ is returned."

15th Aug 2018, 8:17 AM
Ilyich
3 Answers
+ 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
15th Aug 2018, 11:05 AM
Mert Yazıcı
Mert Yazıcı - avatar
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.
15th Aug 2018, 8:55 AM
Steppenwolf
Steppenwolf - avatar
0
How can I overload != ?
15th Aug 2018, 9:51 AM
Ilyich