This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients barry, eli.bendersky, ethan.furman, ncoghlan, pitrou
Date 2013-06-19.06:45:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371624343.74.0.0549181619169.issue17961@psf.upfronthosting.co.za>
In-reply-to
Content
Enum members have two pieces of easily accessible information: `name` and `value`.  The name is taken from the attribute the value is assigned to; the value, obviously, is the value assigned.

The question, then, is what should happen when the function syntax is used, and values are not explicitly given?

  - use `int`s starting from one

  - use `int`s starting from zero

  - use the key name itself

  - use no value at all

Working from the bottom up:

  - no value:  if the enum member has no actual value, the user cannot retrieve the member using the class call syntax (e.g. Color(???) )

  - the key name as value:  if we go this route, then instead of two pieces of info, our enum member has only one piece in two places

  - `int`s from zero:  falls in line with normal Python counting, but is the zeroth member False?

  - `int`s from one: avoids the False question, and it's what flufl.enum does.

No value is obviously a no-go as it causes more problems than it solves.

`str` value is also a no-go as the key name is already available as `name`.

`int`s starting from zero or starting from one?  Personally, I have no problem with a zero-value enum member that is True -- not every zero should be False.  This is the only change I would be willing to make.

To sum up:  the name is already available in the name, no need to have it be the value as well.  I am open to changing the start value to zero instead of one (which is what I do in my customization of Enum in my personal modules ;) .
History
Date User Action Args
2013-06-19 06:45:43ethan.furmansetrecipients: + ethan.furman, barry, ncoghlan, pitrou, eli.bendersky
2013-06-19 06:45:43ethan.furmansetmessageid: <1371624343.74.0.0549181619169.issue17961@psf.upfronthosting.co.za>
2013-06-19 06:45:43ethan.furmanlinkissue17961 messages
2013-06-19 06:45:43ethan.furmancreate