[Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
Barry Warsaw
barry at python.org
Mon Feb 25 21:32:47 CET 2013
More information about the Python-Dev mailing list
Mon Feb 25 21:32:47 CET 2013
- Previous message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Next message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 25, 2013, at 10:25 AM, Ethan Furman wrote: >Hey, I think I just had a light-bulb moment: have the enum implement >__index__ -- that will solve my use-case of using them for list indices. They don't currently, but I think it's reasonable, given that they already support __int__. https://bugs.launchpad.net/flufl.enum/+bug/1132972 >Dumb question, but are flufl.enums ordered? That's also an important use >case. Kind of. Ordered comparisons are explicitly not supported, but iteration over the Enum is guaranteed to be returned in int-value order. One thing I've been thinking about is allowing you to override the EnumValue class that the metaclass uses. In that case, if you really wanted ordered comparisons, you could override __lt__() and friends in a custom enum-value class. I haven't quite worked out in my mind how that would look, but I have a bug to track the feature request: https://bugs.launchpad.net/flufl.enum/+bug/1132976 Heck, that might even allow you to implement int-derived enum values if you really wanted them <wink>. Cheers, -Barry
- Previous message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Next message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list