[issue22504] Add ordering between `Enum` objects

Ram Rachum report at bugs.python.org
Sat Sep 27 16:28:23 CEST 2014


New submission from Ram Rachum:

I suggest making Enum members orderable, according to their order in the enum type. Currently trying to order them raises an exception:

    >>> import enum
    >>> class Number(enum.Enum):
    ...     one = 1
    ...     two = 2
    ...     three = 3
    >>> sorted((Number.one, Number.two))
    Traceback (most recent call last):
      File "<pyshell#2>", line 1, in <module>
        sorted((Number.one, Number.two))
    TypeError: unorderable types: Number() < Number()

If there's agreement from core developers that this is a good feature to add, I'll write a patch.

----------
components: Library (Lib)
messages: 227678
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Add ordering between `Enum` objects
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22504>
_______________________________________


More information about the Python-bugs-list mailing list