hbutils.model.compare¶
- Overview:
Base interface to quickly implement a comparable object.
IComparable¶
-
class
hbutils.model.compare.
IComparable
[source]¶ - Overview:
Interface for a comparable object.
- Examples::
>>> from hbutils.model import IComparable >>> class MyValue(IComparable): ... def __init__(self, v) -> None: ... self._v = v ... ... def _cmpkey(self): ... return self._v ...
>>> MyValue(1) == MyValue(1) True >>> MyValue(1) == MyValue(2) False >>> MyValue(1) != MyValue(2) True >>> MyValue(1) > MyValue(2) False >>> MyValue(1) >= MyValue(2) False >>> MyValue(1) < MyValue(2) True >>> MyValue(1) <= MyValue(2) True