I have a class where I want to override the __eq__() operator. It seems to make sense that I should override the __ne__() operator as well, but does it make sense to implement __ne__ based on __eq__ as such?
class A:
def __eq__(self, other):
return self.value == other.value
def __ne__(self, other):
return not self.__eq__(other)
Or is there something that I'm missing with the way Python uses these operators that makes this not a good idea?
from Python, should I implement __ne__() operator based on __eq__?
0 komentar:
Posting Komentar