[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
scott+python-dev at scottdial.com
Tue Apr 23 17:46:50 CEST 2013
On 4/23/2013 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)",
Reading what you have wrote, it seems that the issue is whether you
consider an instance of Enum a "thing" or a "class of things". If you
think of it as a "thing", then "C" is a object that has attributes for
other "things" that are not like "C". However, if you think of "C" as a
"class of things", then "C" having attributes that are instances of it's
type is completely natural.
Fundamentally, the question is whether an instance of Enum is a new type
or an instance. And for me, it's a new type and I expect enum values to
be instance of that type.
scott at scottdial.com
More information about the Python-Dev