I have a class where I want to override the __eq__
method. It seems to make sense that I should override the __ne__
method as well. Should I implement __ne__
as the negation of __eq__
as such or is it a bad idea?
class A:
def __init__(self, state):
self.state = state
def __eq__(self, other):
return self.state == other.state
def __ne__(self, other):
return not self.__eq__(other)
所有评论(0)