add GPC.__eq__() and .__ne__()

This commit is contained in:
Lance Edgar 2012-11-18 08:36:18 -08:00
parent c1987780b2
commit 92abd79a97

View file

@ -63,6 +63,18 @@ class GPC(object):
value += str(barcodes.upc_check_digit(value))
self.value = int(value)
def __eq__(self, other):
try:
return int(self) == int(other)
except (TypeError, ValueError):
return False
def __ne__(self, other):
try:
return int(self) != int(other)
except (TypeError, ValueError):
return True
def __cmp__(self, other):
if int(self) < int(other):
return -1