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
Barry A. Warsaw added the comment:
On Sep 27, 2014, at 02:28 PM, Ram Rachum wrote:
I suggest making Enum members orderable, according to their order in the enum
type.
Can you please provide a motivating use case?
--
nosy: +barry
___
Python tracker
Antoine Pitrou added the comment:
Why don't you use IntEnum?
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22504
___
___
Ram Rachum added the comment:
Just because I want to be able to get the `int` value of an enum object,
doesn't mean I want the enum object to *be* an `int`, which is what `IntEnum`
means. I don't want it to be comparable to an int, I don't want to use
arithmetic on it, and most importantly I
Barry A. Warsaw added the comment:
On Sep 27, 2014, at 03:35 PM, Ram Rachum wrote:
Just because I want to be able to get the `int` value of an enum object,
doesn't mean I want the enum object to *be* an `int`, which is what `IntEnum`
means. I don't want it to be comparable to an int, I don't
Barry A. Warsaw added the comment:
https://docs.python.org/3/library/enum.html#orderedenum
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22504
___
Ram Rachum added the comment:
My particular use case is that I have objects with a tuple of enum objects to
each, and I want the tuple to be in canonical order rather than random, for
convenience.
I can easily use a subclass, but I think it's general enough functionality for
it to be
Changes by Ethan Furman et...@stoneleaf.us:
--
nosy: +ethan.furman
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22504
___
___
Python-bugs-list
Ethan Furman added the comment:
Enums have a definition order to aid in the use-case of auto-numbering, and to
make displays consistent. However, the basic Enum type is unordered.
If you need/want your particular enum type to be ordered, mix-in the ordered
magic methods.
--