On 04/29/2013 09:30 AM, Larry Hastings wrote:

On 04/29/2013 06:51 AM, Eli Bendersky wrote:
flufl.enum disallows this:

class Color(Enum):
  red = 1
  blue = 2
  green = 1 # oops!

Has it been decided that this is now allowed? If this is indeed the case, then 
Color(1) is a problem. The options are:

At this point I think the best course is to not allow duplicates directly in the enum definition, but allow them after the fact:

--> class Color(Enum):
...     red = 1
...     green = 2
...     blue = 3

--> Color.grene = Color.green  # stupid legacy typo

This gives us both some protection against accidental duplicates, while still allowing them when necessary; also, no confusion about which is the canonical name.

Guido?

--
~Ethan~
_______________________________________________
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