1class A: 2 def __eq__(self, other): 3 print("A __eq__ called") 4 return True 5 6class B: 7 def __ne__(self, other): 8 print("B __ne__ called") 9 return True 10 11class C: 12 def __eq__(self, other): 13 print("C __eq__ called") 14 return False 15 16class D: 17 def __ne__(self, other): 18 print("D __ne__ called") 19 return False 20 21a = A() 22b = B() 23c = C() 24d = D() 25 26def test(s): 27 print(s) 28 print(eval(s)) 29 30for x in 'abcd': 31 for y in 'abcd': 32 test('{} == {}'.format(x,y)) 33 test('{} != {}'.format(x,y)) 34