On 04/29/2013 08:39 AM, Guido van Rossum wrote:
Indeed, the "type(Color.red) is Color" claim was meant for the
situation where red is defined directly in Color, and I used type()
instead of isinstance() because Barry was proposing to overload
isinstance() to make this true without equating the classes. But for
the subclass case, I want MoreColor.red is Color.red and
isinstance(MoreColor.red, Color), but not isinstance(Color.red,
MoreColor). If you can't live with that, don't subclass enums.

So if I understand:

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

--> class MoreColor(Color):
...     cyan = 4
...     magenta = 5
...     yellow = 6

--> type(MoreColor.red) is Color

--> type(MoreColor.red) is not MoreColor

In other words, while `red` is accessible in MoreColor, it's actually a Color 
instance?

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