On 04/30/2013 09:47 PM, Barry Warsaw wrote:
On Apr 30, 2013, at 07:39 PM, Glenn Linderman wrote:

Because Guido said no subclassing.

Indeed, I heard him.  But what I heard was that subclasses shouldn't be
allowed to define new enumeration values, and that was the point of all his
justification and the justifications in the Stack Overflow discussion he
linked to. I don't want to disagree, or argue that point, there are reasons
for it, although some have raised counter-arguments to it.  This is not
intended to be a counter-argument to the point that there should be no new
enumeration values created in subclasses.

That's a shame, because disallowing subclassing to extend an enum will break
my existing use cases.  Maybe I won't be able to adopt stdlib.enums after
all. :(

What is your existing use case?

The way I had subclassing working originally was for the subclass to create it's own versions of the superclass' enum items -- they weren't the same object, but they were equal:

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

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

--> Color.red is MoreColor.red
False

--> Color.red == MoreColor.red
True

If you switched from `is` to `==` would this work for you?

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