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

2013-04-21 Thread Guido van Rossum
On Sun, Apr 21, 2013 at 5:55 PM, Tim Delaney wrote: > On 22 April 2013 10:31, Barry Warsaw wrote: >> >> On Apr 22, 2013, at 09:31 AM, Tim Delaney wrote: >> >> >I'm fine with iteration order being by sorted name by default, so long as >> >it's easily overrideable by enum subclasses or metaclasses

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

2013-04-21 Thread R. David Murray
On Sun, 21 Apr 2013 20:28:16 -0400, Barry Warsaw 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 =

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

2013-04-21 Thread Tim Delaney
On 22 April 2013 10:31, Barry Warsaw wrote: > On Apr 22, 2013, at 09:31 AM, Tim Delaney wrote: > > >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. >

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

2013-04-21 Thread Nick Coghlan
On Mon, Apr 22, 2013 at 10:28 AM, Barry Warsaw 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 >>Th

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

2013-04-21 Thread Barry Warsaw
On Apr 22, 2013, at 09:31 AM, Tim Delaney wrote: >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. It does. :) >For definition order, a 3.x-only metaclass

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

2013-04-21 Thread Barry Warsaw
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 Sorr

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

2013-04-21 Thread Tim Delaney
On 22 April 2013 09:02, Nick Coghlan wrote: > > On 22 Apr 2013 07:50, "Barry Warsaw" 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,

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

2013-04-21 Thread Nick Coghlan
On 22 Apr 2013 07:50, "Barry Warsaw" 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

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

2013-04-21 Thread Barry Warsaw
On Apr 22, 2013, at 12:06 AM, Steven D'Aprano wrote: >On 21/04/13 15:33, Nick Coghlan wrote: > >> The PEP is fine, as it already allows duplicate names without encouraging >> them: >> >> class Insect(Enum): >> wasp = 1 # Preferred. Use this in new code. >> bee = 2 >>

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

2013-04-21 Thread Barry Warsaw
On Apr 21, 2013, at 03:25 PM, Nick Coghlan wrote: >Agreed. I think the stdlib enum library should use __prepare__ and >iterate in definition order (since 2.x compatibility isn't of any >concern), while flufl.enum can use "sorted by name" as the iteration >order. > >An "order_by_name" keyword argum

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

2013-04-21 Thread Guido van Rossum
Fine with me. On Sun, Apr 21, 2013 at 2:47 PM, Barry Warsaw 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 iterat

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

2013-04-21 Thread Barry Warsaw
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 e

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

2013-04-21 Thread Steven D'Aprano
On 21/04/13 15:33, Nick Coghlan wrote: The PEP is fine, as it already allows duplicate names without encouraging them: class Insect(Enum): wasp = 1 # Preferred. Use this in new code. bee = 2 ant = 3 # Backwards compatibility aliases Insect.wsap = Insec

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

2013-04-21 Thread Tim Delaney
On 21 April 2013 21:02, Greg Ewing wrote: > Barry Warsaw wrote: > >> On Apr 13, 2013, at 12:51 PM, Steven D'Aprano wrote: >> > > class Insect(Enum): >>>wasp = wsap = 1 >>>bee = 2 >>>ant = 3 >>> >>> What's the justification for this restriction? I have looked in the PEP, >>> and >>> d

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

2013-04-21 Thread Greg Ewing
Barry Warsaw wrote: On Apr 13, 2013, at 12:51 PM, Steven D'Aprano wrote: class Insect(Enum): wasp = wsap = 1 bee = 2 ant = 3 What's the justification for this restriction? I have looked in the PEP, and didn't see one. If you allowed this, there would be no way to look up an enumera