From a68d6df9303570aaf035937e0938b87e140b8187 Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Mon, 17 Oct 2016 09:18:02 +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: I3df4396495e3404e2c644c769693f89b7c01537a --- os_apply_config/oac_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/os_apply_config/oac_file.py b/os_apply_config/oac_file.py index c09b6e0..0a39059 100644 --- a/os_apply_config/oac_file.py +++ b/os_apply_config/oac_file.py @@ -47,6 +47,9 @@ class OacFile(object): return self.__dict__ == other.__dict__ return False + def __ne__(self, other): + return not self.__eq__(other) + def __repr__(self): a = ["OacFile(%s" % repr(self.body)] for key, default in six.iteritems(self.DEFAULTS):