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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to