A more concise example for OrederedEnum
2 Sep
2013
2 Sep
'13
5:19 p.m.
Instead of implementing 4 comparison methods, I suggest using total_ordering:
from functools import total_ordering @total_ordering ... class OrderedEnum(Enum): ... def __gt__(self, other): ... if self.__class__ is other.__class__: ... return self.value > other.value ... return NotImplemented ...
I believe the reader needn't be famiiar with total_ordering() to understand what's going on here. elazar
4151
Age (days ago)
4151
Last active (days ago)
0 comments
1 participants
participants (1)
-
אלעזר