From 2fa1fd661dedbb9159e0462d1fa69205fff370f4 Mon Sep 17 00:00:00 2001 From: melissaml Date: Wed, 19 Oct 2016 04:34:14 +0800 Subject: [PATCH] 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: If2cc9f72acbc444df107f95bded08a398a5d8be3 --- magnumclient/common/apiclient/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/magnumclient/common/apiclient/base.py b/magnumclient/common/apiclient/base.py index 72754410..f291a1e1 100644 --- a/magnumclient/common/apiclient/base.py +++ b/magnumclient/common/apiclient/base.py @@ -521,6 +521,9 @@ class Resource(object): return self.id == other.id return self._info == other._info + def __ne__(self, other): + return not self.__eq__(other) + def is_loaded(self): return self._loaded