A NummedObj instance cannot be compared for equality or non-equality against arbitrary objects:
>>> from pyutil.nummedobj import NummedObj
>>> class X(NummedObj): pass
...
>>> x = X()
>>> x == 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/9ms6vnn4iakl4aix85ygc7ana5kshhj1-python3-3.9.6-env/lib/python3.9/site-packages/pyutil/nummedobj.py", line 41, in __eq__
return (self._objid, self._classname,) == (other._objid, other._classname,)
AttributeError: 'int' object has no attribute '_objid'
>>> x != 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/9ms6vnn4iakl4aix85ygc7ana5kshhj1-python3-3.9.6-env/lib/python3.9/site-packages/pyutil/nummedobj.py", line 44, in __ne__
return (self._objid, self._classname,) != (other._objid, other._classname,)
AttributeError: 'int' object has no attribute '_objid'
>>>
But the typical assumption would be that since x is not very similar to 1, x == 1 would evaluate to False and x != 1 would evaluate to True.
This broken assumption causes problems in a number of places since it means NummedObj instances don't really implement the equality protocol, only a subset of it.
A
NummedObjinstance cannot be compared for equality or non-equality against arbitrary objects:But the typical assumption would be that since
xis not very similar to1,x == 1would evaluate toFalseandx != 1would evaluate toTrue.This broken assumption causes problems in a number of places since it means
NummedObjinstances don't really implement the equality protocol, only a subset of it.