functools.total_ordering#
The module functools provides a decorator total_ordering that makes it less cumbersome to define a class that be used with the comparison operators ==, !=, <, <=, >, and >=.
A class decorated with total_ordering must define:
the dunder method
__eq__; andone of
__lt____le____gt____ge__
This decorator is cumbersome to implement but it isn’t technically very challenging, provided you know how to work with dunder methods.