functools.total_ordering: Define two comparison methods, get six

functools.total_ordering: Define two comparison methods, get six

Python tip: Don’t write all 6 comparison methods!

Define __eq__ and __lt__, then add @total_ordering:

from functools import total_ordering
@total_ordering
class C:
    def __lt__(self, o): ...
    def __eq__(self, o): ...

You get >, >=, <= for free!