summaryrefslogtreecommitdiff
path: root/keystoneclient/base.py
diff options
context:
space:
mode:
authoryuyafei <yu.yafei@zte.com.cn>2016-07-05 15:21:02 +0800
committeryuyafei <yu.yafei@zte.com.cn>2016-08-11 11:19:30 +0800
commitef34175095d92a117fda149ad8a2e216e3a2b78c (patch)
tree5f22e77174783ca3a6911a51113b2c00b539c39d /keystoneclient/base.py
parent64d458fcf8c2f7eab24f0134f3c27e15c181fe15 (diff)
downloadpython-keystoneclient-ef34175095d92a117fda149ad8a2e216e3a2b78c.tar.gz
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__ Also fixes spelling errors:resoruces. Change-Id: Iae4ce0fe84fae810711cc8c3fdb94eb9ca1d772e Closes-Bug: #1586268
Diffstat (limited to 'keystoneclient/base.py')
-rw-r--r--keystoneclient/base.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py
index d028d97..3f13a6c 100644
--- a/keystoneclient/base.py
+++ b/keystoneclient/base.py
@@ -523,6 +523,10 @@ class Resource(object):
return False
return self._info == other._info
+ def __ne__(self, other):
+ """Define inequality for resources."""
+ return not self == other
+
def is_loaded(self):
return self._loaded