Ethan Furman added the comment:

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 ;) .

----------
assignee:  -> ethan.furman
nosy: +eli.bendersky
title: Use enum names as values in enum.Enum convenience API -> Use enum names 
as values in enum.Enum() functional API

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17961>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to