You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
A
NummedObj
instance cannot be compared for equality or non-equality against arbitrary objects:But the typical assumption would be that since
x
is not very similar to1
,x == 1
would evaluate toFalse
andx != 1
would evaluate toTrue
.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.The text was updated successfully, but these errors were encountered: