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: I1526522261cc315c91472b4342aa8842637db56c
This commit is contained in:
gecong1973
2016-09-05 09:32:53 +08:00
parent c1b1ae3657
commit 1812be06b2

View File

@@ -183,6 +183,9 @@ class Requirement(object):
return (isinstance(other, self.__class__) and
self.package_name == other.package_name)
def __ne__(self, other):
return not self.__eq__(other)
def parse_data(raw_data, include_comments=True):
# first elem is None to simplify checks of last elem in requirements