[docs] A more concise example for OrederedEnum

אלעזר elazarg at gmail.com
Tue Sep 3 02:19:36 CEST 2013

Instead of implementing 4 comparison methods, I suggest using

>>> 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130903/4c78fbad/attachment.html>

More information about the docs mailing list