From 57be21cd16ca8c9b880715ea7d96075b809eb1bc Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Tue, 29 Nov 2016 09:25:45 +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: I52d4b7396136dd3be7b8767dccb0613e8faba536 --- monascaclient/apiclient/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/monascaclient/apiclient/base.py b/monascaclient/apiclient/base.py index c3ce77b..ca7de87 100644 --- a/monascaclient/apiclient/base.py +++ b/monascaclient/apiclient/base.py @@ -485,6 +485,9 @@ class Resource(object): return self.id == other.id return self._info == other._info + def __ne__(self, other): + return not self.__eq__(other) + @property def is_loaded(self): return self._loaded