A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-May/125798.html below:

[Python-Dev] PEP-435 reference implementation

[Python-Dev] PEP-435 reference implementationEthan Furman ethan at stoneleaf.us
Wed May 1 07:50:31 CEST 2013
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~
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4