steenzout.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 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
API documentation¶
This section contains information on a specific function, class, or method, this part of the documentation is for you.