What is the meaning of these lines | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

What is the meaning of these lines

If __ne__ is not implemented, it returns the opposite of __eq__. There are no other relationships between the other operators.

17th Jul 2018, 11:51 AM
adarsh pandey
adarsh pandey - avatar
2 Answers
+ 5
class Class: def __init__(self, a): self.a = a def __eq__(self, other): return self.a == 'a' and other == 'b' a = Class('a') print(a == 'b') print(a != 'b') #not a == 'b'
17th Jul 2018, 3:32 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
check out the comments in the lesson.
17th Jul 2018, 12:26 PM