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.
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.
_______________________________________________
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