[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

Serhiy Storchaka storchaka at gmail.com
Fri Apr 26 11:16:34 CEST 2013

26.04.13 11:00, Greg Ewing написав(ла):
> However, there's a worse problem with defining enum
> inheritance that way. The subtype relation for extensible
> enums works the opposite way to that of classes.
> To see this, imagine a function expecting something
> of type Colors. It knows what to do with red, green and
> blue, but not anything else. So you *can't* pass it
> something of type MoreColors, because not all values
> of type MoreColors are of type Colors.

This is why enums are not subclassable in other languages (i.e. Java).

More information about the Python-Dev mailing list