[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)

Barry Warsaw barry at python.org
Fri Apr 26 00:02:18 CEST 2013


On Apr 25, 2013, at 02:54 PM, Guido van Rossum wrote:

I don't know what's going on,

Mostly that this is my first opportunity to chime in on the subject.

but it feels like we had this same discussion a week ago, and I still disagree. Disregarding, the C[i] notation, I feel quite strongly that in the following example:

class Color(Enum): red = 1 white = 2 blue = 3 orange = 4 the values Color.red etc. should be instances of Color. This is how things work in all other languages that I am aware of that let you define enums.

Is it enough that isinstance(Color.red, Color) returns True, or do you really-and-truly want them to be instances of Color?

I still think it's weird, but I could accept the former if you're flexible on the latter, which in some sense is just an implementation detail anyway.

-Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20130425/00ad0592/attachment.pgp>



More information about the Python-Dev mailing list