[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

R. David Murray rdmurray at bitdance.com
Mon Apr 22 03:12:05 CEST 2013


On Sun, 21 Apr 2013 20:28:16 -0400, Barry Warsaw <barry at python.org> wrote:
> On Apr 22, 2013, at 09:02 AM, Nick Coghlan wrote:
> 
> >Iteration order matters a lot if you don't want people complaining about
> >enums being broken:
> >
> >  class Days(enum.Enum):
> >    Monday = 1
> >    Tuesday = 2
> >    Wednesday = 3
> >    Thursday = 4
> >    Friday = 5
> >    Saturday = 6
> >    Sunday = 7
> 
> Sorry, that's still not a complete use case.  I don't see why you'd depend on
> iteration order over Days for any particular functionality.  Besides, if you
> did, I think it would be better to derive Days from IntEnum and then iteration
> order is guaranteed over the values.

I didn't read Nick's message as being about a use case.  The key word in
the sentence above was "complaining" :)

Regardless of the specific values involved, it is pretty much guaranteed
that if anything other than definition order is used we *will* get bug
reports/enhancement requests to fix it, on a regular basis.  We can choose
to live with that, but we should admit that it will will happen :)

--David


More information about the Python-Dev mailing list