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

Barry Warsaw barry at python.org
Thu Apr 25 20:50:12 CEST 2013


On Apr 23, 2013, at 10:24 AM, R. David Murray wrote:

>> >>> isinstance(C.a, C)
>> False
>> >>> isinstance(C(1), C)
>> False
>> 
>> It would really be better if instances were actual instances of the
>> class, IMO.
>
>The first False looks correct to me, I would not expect an enum value to be
>an instance of the class that holds it as an attribute.

Agreed, completely.

>The second certainly looks odd, but what does it even mean to have an
>instance of an Enum class?

It only looks odd because it's using failed, duplicate, deprecated syntax.
Does this look similarly odd?

>>> isinstance(C[1], C)
False

given that ``C[1] is C.a``?

-Barry


More information about the Python-Dev mailing list