[issue22505] Expose an Enum object's serial number

2014-09-28 Thread Eli Bendersky
Eli Bendersky added the comment: >> I could continue the discussion about databases, but it feels like a waste >> of time to me. The main principle is: If something has an important property >> (in this case an enum object's numerical value), it should be publicly >> exposed. Period. No need t

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Ethan Furman
Ethan Furman added the comment: Yes, we're sure. ;) 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. I do not see a serial number as being an intrinsic property of an enum -- outside of auto-n

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Ram Rachum
Ram Rachum added the comment: > Enum members are also defined to be unordered, so their serial number is > meaningless. Are you sure? The documentation says "Enumerations support iteration, in definition order" and shows how `tuple(MyEnum)` outputs the values in definition order. > Likewise

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Sep 27, 2014, at 04:15 PM, Ram Rachum wrote: >The main principle is: If something has an important property (in this case >an enum object's numerical value), it should be publicly exposed. I think this is a misunderstanding. Only IntEnum members have a def

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Ram Rachum
Ram Rachum added the comment: > https://docs.python.org/3/library/enum.html#orderedenum As I said in the other ticket: I can easily use a subclass, but I think it's general enough functionality for it to be included in the standard library. I could continue the discussion about databases, but

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Sep 27, 2014, at 02:59 PM, Ram Rachum wrote: >Right now I want it for this: > >http://bugs.python.org/issue22504 https://docs.python.org/3/library/enum.html#orderedenum >Another use case I can think of is that if you store enum values in a >database, you'

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Ram Rachum
Ram Rachum added the comment: Right now I want it for this: http://bugs.python.org/issue22504 Another use case I can think of is that if you store enum values in a database, you're probably using an int field and you'd want to easily convert between an enum and it's int value. -- _

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Sep 27, 2014, at 02:40 PM, Ram Rachum wrote: >I'd like Enum objects to expose their serial numbers. Can you please provide some motivating use cases? -- ___ Python tracker __

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +barry, eli.bendersky, ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue22505] Expose an Enum object's serial number

2014-09-27 Thread Ram Rachum
New submission from Ram Rachum: I'd like Enum objects to expose their serial numbers. Currently it seems the only way to get this is `MyEnum._member_names_.index(my_enum.name)`, which is not cool because it's cumbersome and involves private variables. Perhaps we can use `int(my_enum) == 7`? Or