import functools @functools.total_ordering class TestTotalOrdering: def __init__(self, value): self.value = value def __eq__(self, other): if isinstance(other, TestTotalOrdering): return self.value == other.value return False def __lt__(self, other): if isinstance(other, TestTotalOrdering): return self.value < other.value raise TypeError tto = TestTotalOrdering(8) print(tto <= ())