On 22 April 2013 09:02, Nick Coghlan <ncogh...@gmail.com> wrote:

>
> On 22 Apr 2013 07:50, "Barry Warsaw" <ba...@python.org> wrote:
> >
> > On Apr 20, 2013, at 07:10 PM, R. David Murray wrote:
> >
> > >It seems strange to limit a new Python3 feature to the Python2 feature
> > >set.  Just saying :)
> >
> > For a critical feature sure, but I don't put __repr__ or enum item
> iteration
> > order in that category.  There's no need for gratuitous incompatibility
> > either, and attribute name order is just fine.
>
> 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
>
I'm fine with iteration order being by sorted name by default, so long as
it's easily overrideable by enum subclasses or metaclasses e.g. an IntEnum
should probably iterate in value order.

For definition order, a 3.x-only metaclass could be provided:

class Days(enum.Enum, metaclass=enum.DefinitionOrder):
    Monday = 1
    Tuesday = 2
    Wednesday = 3
    Thursday = 4
    Friday = 5
    Saturday = 6
    Sunday = 7

Tim Delaney
_______________________________________________
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