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:

A. Return either Color.red or Color.green
B. Throwing an error

Do we have a decision on this? Personally I think the latter is better; the former is error prone and doesn't seem to be useful too often.

Eli [trying to tie loose ends for updating the PEP].

Would you disallow this too?

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


IMO the more Pythonic behavior would be to allow multiple names for the same value, and your example should produce the same result as my example. I'm not convinced enums are special enough to break the rules.

See also "consenting adults",


//arry/
_______________________________________________
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