python equality precedence
问题 class L(object): def __eq__(self, other): print 'invoked L.__eq__' return False class R(object): def __eq__(self, other): print 'invoked R.__eq__' return False left = L() right = R() With this code, left side gets the first shot at comparison, as documented in the data model: >>> left == right invoked L.__eq__ False But if we make a slight modification on line 6 (everything else the same): class R(L): Now the right side gets to have the first shot at comparison. >>> left == right invoked R._