Add __ne__ built-in function
In Python 3 __ne__ by default delegates to __eq__ and inverts the result, but in Python 2 they urge you to define __ne__ when you define __eq__ for it to work properly [1].There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__() so that the operators will behave as expected. [1]https://docs.python.org/2/reference/datamodel.html#object.__ne__ Change-Id: I6b43b9ac33b4f6e6331b390366e68f2a5bbb997c
This commit is contained in:
parent
50af3b6bb8
commit
dfdee212cc
@ -521,6 +521,9 @@ class Resource(object):
|
|||||||
return self.id == other.id
|
return self.id == other.id
|
||||||
return self._info == other._info
|
return self._info == other._info
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return not self.__eq__(other)
|
||||||
|
|
||||||
def is_loaded(self):
|
def is_loaded(self):
|
||||||
return self._loaded
|
return self._loaded
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user