summaryrefslogtreecommitdiff
path: root/python/transform.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2020-05-02 11:01:35 -0400
committerPeter LaFosse <peter@vector35.com>2020-05-03 13:20:56 -0400
commit8f1bc5944b849f3ad0cbbd5972d5ab9948ed4d57 (patch)
tree43b48da8a1ec93b148575bc3346059e5316e6bf6 /python/transform.py
parent5b84fdea8abcb4abba61d07e0d12b4115b516c52 (diff)
Fix up equality operators and had hash operators
Diffstat (limited to 'python/transform.py')
-rw-r--r--python/transform.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/python/transform.py b/python/transform.py
index 946b349b..3e89555d 100644
--- a/python/transform.py
+++ b/python/transform.py
@@ -166,15 +166,18 @@ class Transform(with_metaclass(_TransformMetaClass, object)):
def __repr__(self):
return "<transform: %s>" % self.name
- def __eq__(self, value):
- if not isinstance(value, Transform):
- return False
- return ctypes.addressof(self.handle.contents) == ctypes.addressof(value.handle.contents)
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents)
- def __ne__(self, value):
- if not isinstance(value, Transform):
- return True
- return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents)
+ def __ne__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ return not (self == other)
+
+ def __hash__(self):
+ return hash(ctypes.addressof(self.handle.contents))
def _get_parameters(self, ctxt, count):
try: