[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
barry at python.org
Thu Apr 25 21:20:10 CEST 2013
On Apr 23, 2013, at 10:53 AM, R. David Murray wrote:
>Ah. I'd be looking for a bug every time I saw isinstance(value,
>myEnumClass). A better class name for values and an API for getting that
>class from the EnumClass would be nice, though. (So that you could write
>"isinstance(value, MyEnumClass.ValueClass)", say.)
I think if we did this, the attribute should be the same name as the one used
to customize the value factory. Okay, this is horrible, but you could use
The only thing stopping you from doing this right now is that when
__value_factory__ is not given, a default is used which is not available on
that attribute. That's easily corrected though.
1) really, to be consistent with the documentation, this should be
__item_factory__ since the attributes of the enum class are called "items",
while items have an underlying value (e.g. A.b.value).
2) A better name than either __item_factory__ or __value_factory__ is welcome,
though I guess that will spawn another bikeshedding, soul-destroying
3) I'd like to make the implementation names consistent with the documentation
in the next version of flufl.enum.
More information about the Python-Dev