PEP 354: Enumerations in Python

Crutcher crutcher at gmail.com
Mon Feb 27 01:30:28 EST 2006


This seems great, except why can't I compare strings? It seems too
useful when dealing with user input, or parsing messages or config
files.

>>> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
>>> Weekdays.mon.__cmp__('mon')
0

Additionaly, perhaps the call method of the enumeration object should
construct a value from strings?
>>> Weekdays.mon == Weekdays('mon')




More information about the Python-list mailing list