python-object
The steenzout.object
package provides an Object
class with
pre-defined __hash__
, __eq__
and __ne__
functions.
What's the difference to the object
class?
Example:
>>> o1 = object()
>>> o2 = object()
>>>
>>> assert o1 == o2
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
If you use steenzout.object.Object
:
>>> from steenzout.object import Object
>>>
>>> o1 = Object()
>>> o2 = Object()
>>>
>>> assert o1 == o2
>>>
If you sub-class the Object
class,
==
and !=
will still work as expected:
>>> class A(Object):
>>> pass
...
...
>>> class B(Object):
>>> pass
...
...
>>> a = A()
>>> b = B()
>>> a == b
>>> False
>>> a != b
>>> True
Test
$ tox
Documentation
$ tox -e docs