PEP 354: Enumerations in Python
I V
wrongbad at gmail.com
Mon Feb 27 18:10:43 EST 2006
Paul Rubin wrote:
> Hmm, I also see the PEP doesn't specify what's supposed to happen with
>
> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
> Solar_system = enum('sun', 'mercury', 'venus', 'earth',) # etc.
> print Weekdays.sun == Solar_system.sun
>
> so that's another shortcoming with the PEP.
I think it does, doesn't it? From the PEP:
"Values within an enumeration cannot be meaningfully compared *except
with values from the same enumeration*. The comparison operation
functions return ``NotImplemented`` [#CMP-NOTIMPLEMENTED]_ when a
value from an enumeration is compared against any value not from the
same enumeration or of a different type." (my emphasis)
More information about the Python-list
mailing list