On 04/28/2013 09:54 PM, Guido van Rossum wrote:
On Sunday, April 28, 2013, Ethan Furman wrote:

Enums are the same: they could return brand new instances every time, and 
programs using `==` to compare will keep
on working.  That they don't is an implementation detail.

Whoa. In this case the identity property is not just an implementation issue, 
it is part of the spec. Same for bool.
(But == works too.)

I realize that, and I have no problems with the singleton (multiton?) approach; however, part of the spec is that a subclass shares the enum items, and if the enum items are actual instances of the type that will no longer be correct.

In other words, currently:

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

  class MoreColor(Color):
      cyan = 4
      magenta = 5
      yellow = 6
      black = 7

  MoreColor.red is Color.red  # True

But as soon as:

  type(Color.red) is Color          # True
  type(MoreColor.red) is MoreColor  # True

then:

   Color.red is MoreColor.red  # must be False, no?


If that last statement can still be True, I'd love it if someone showed me how.

--
~Ethan~

P.S.  Apologies for the additional post.
_______________________________________________
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