[Python-ideas] Enums

Barry Warsaw barry at python.org
Thu Jul 28 19:27:47 CEST 2011


On Jul 28, 2011, at 02:49 PM, Ben Finney wrote:

>What I'd hold out for, though, is::
>
>    >>> Color.red == Fruit.tomato
>    False
>
>That is, all of the values from Color should compare as inequal with any
>other value.

Does it have to be an equality test, or is identity tests enough?

>This is one of the main features to want from an enumerated type, IMO:
>to have a set of values that are distinct from any other value, that
>won't be accidentally equal to any other value, and have helpful string
>representations.
>
>> (Here I am consistent with the behavior of True and False.)
>
>Do you see that (the behaviour of True and False comparing equal with
>integers) as anything more than backward-compatible baggage?
>
>To me, if I had the time machine, a proper representation of a boolean
>type would have True and False as distinct values, never comparing equal
>with any other value.

Except possibly for ancient modules, does anybody still actually use the
int-iness of bools explicitly?

-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-ideas/attachments/20110728/48dbe0e7/attachment.pgp>


More information about the Python-ideas mailing list