[Python-Dev] PEP 435 - ref impl disc 2
v+python at g.nevcal.com
Mon May 6 04:46:55 CEST 2013
On 5/5/2013 7:14 PM, Nick Coghlan wrote:
> I think there comes a point where "subclass the metaclass" is the
> right answer to "how do I do X with this type?". I believe making two
> different kinds of value labelling mechanisms play nice is such a case
Could be that sufficient operators added to an IntEnum subclass might
work too. Although it might be unexpected that adding two enumeration
members would produce a NamedInt :) But of course, if the enumeration
were defined by NamedIntEnum, it might be less surprising.
On the other hand, if Enum is in stdlib, and lots of flags parameters
get defined with Enum, then it would be a pain in the neck to redefine
them with NamedIntEnum, so that debugging of flag combinations is
easier. There are enough flag parameters in the stdlib APIs to make me
think this would be a deficiency.
Sadly, once the Enums are defined, there is to be no way to subclass
them to add functionality, like producing a NamedInt result from
operations on them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev