From 0cfeff4d82cdc8a8ca9ed5bb2937b929ae041e9a Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Mon, 17 Oct 2016 10:04:46 +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: Iacd368b64650bf7eabd342a236339d1711aea4cd --- dracclient/resources/bios.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dracclient/resources/bios.py b/dracclient/resources/bios.py index 7669f01..a4c3683 100644 --- a/dracclient/resources/bios.py +++ b/dracclient/resources/bios.py @@ -278,6 +278,9 @@ class BIOSAttribute(object): def __eq__(self, other): return self.__dict__ == other.__dict__ + def __ne__(self, other): + return not self.__eq__(other) + @classmethod def parse(cls, namespace, bios_attr_xml): """Parses XML and creates BIOSAttribute object"""