Re: [Python-Dev] AutoNumber Enum

2016-06-30 Thread Wes Turner
It may be worth mentioning that pandas Categoricals are mutable and zero-based: https://pandas-docs.github.io/pandas-docs-travis/categorical.html Serialization to SQL and CSV is (also?) lossy, though: - https://pandas-docs.github.io/pandas-docs-travis/categorical.html#getting-data-in-out -

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ethan Furman
On 06/29/2016 03:40 PM, Roberto Martínez wrote: Why the 'start' parameter default is 1? 0 (zero) is more consistent with other parts of the language: indexes, enumerate, range... An excerpt from [1]: The reason for defaulting to 1 as the starting number and not 0 is that 0 is False in a

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Roberto Martínez
Why the 'start' parameter default is 1? 0 (zero) is more consistent with other parts of the language: indexes, enumerate, range... El mié., 29 de jun. de 2016 21:26, Ethan Furman escribió: > On 06/29/2016 12:11 PM, Guido van Rossum wrote: > > > And how would you implement

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ivan Levkivskyi
> Presumably you want a bitfield enum, and those should descend from IntEnum. Yes, and probably having an AutoNumberIntEnum would indeed be too much magic in one place. Anyway, it is easy to implement bitfield IntEnum without magic. To be clear, I like the Ethan's original proposal. -- Ivan

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Larry Hastings
On 06/29/2016 01:01 PM, Ivan Levkivskyi wrote: It looks like the values in AutoNumberEnum are consecutive integers 1,2,3,... Have you considered an option (keyword argument) to change this to powers of two 1,2,4,8,...? Why would you want that? I remind you that this descends from Enum, so

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ethan Furman
On 06/29/2016 01:01 PM, Ivan Levkivskyi wrote: It looks like the values in AutoNumberEnum are consecutive integers 1,2,3,... Have you considered an option (keyword argument) to change this to powers of two 1,2,4,8,...? There is another issue relating to bitwise enums that deals with that. It

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ivan Levkivskyi
It looks like the values in AutoNumberEnum are consecutive integers 1,2,3,... Have you considered an option (keyword argument) to change this to powers of two 1,2,4,8,...? -- Ivan On 29 June 2016 at 21:23, Ethan Furman wrote: > On 06/29/2016 12:11 PM, Guido van Rossum

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ethan Furman
On 06/29/2016 12:11 PM, Guido van Rossum wrote: And how would you implement that without support from the compiler? Does it use a hook that catches the NameError? It's built into the _EnumDict class dictionary used during class creation. Current (edited) code from the aenum package that

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Ethan Furman
On 06/29/2016 11:15 AM, Brett Cannon wrote: On Wed, 29 Jun 2016 at 10:41 Ethan Furman wrote: There is a several-month-old request to add aenum's [1] AutoNumberEnum to the stdlib [2]. The requester and two of the three developers of Enum are in favor (the third hasn't chimed in yet). This

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Guido van Rossum
And how would you implement that without support from the compiler? Does it use a hook that catches the NameError? On Wed, Jun 29, 2016 at 11:15 AM, Brett Cannon wrote: > > > On Wed, 29 Jun 2016 at 10:41 Ethan Furman wrote: >> >> There is a

Re: [Python-Dev] AutoNumber Enum

2016-06-29 Thread Brett Cannon
On Wed, 29 Jun 2016 at 10:41 Ethan Furman wrote: > There is a several-month-old request to add aenum's [1] AutoNumberEnum > to the stdlib [2]. > > The requester and two of the three developers of Enum are in favor (the > third hasn't chimed in yet). > > This new addition

[Python-Dev] AutoNumber Enum

2016-06-29 Thread Ethan Furman
There is a several-month-old request to add aenum's [1] AutoNumberEnum to the stdlib [2]. The requester and two of the three developers of Enum are in favor (the third hasn't chimed in yet). This new addition would enable the following: from Enum import AutoNumberEnum class