python - Does __ne__ use an overridden __eq__? -
suppose have following program:
class a(object): def __eq__(self, other): return true a0 = a() a1 = a() print a0 != a1 if run python output true. question
- the
__ne__method not implemented, python fall on default one? - if python fall on default method determine whether 2 objects equal or not, shouldn't call
__eq__, negate result?
from the docs:
there no implied relationships among comparison operators. truth of
x==ynot implyx!=yfalse. accordingly, when defining__eq__(), 1 should define__ne__()operators behave expected.
Comments
Post a Comment