PEP 354: Enumerations in Python
tzot at sil-tec.gr
Fri Mar 3 10:19:08 CET 2006
On 26 Feb 2006 22:30:28 -0800, rumours say that "Crutcher"
<crutcher at gmail.com> might have written:
>This seems great, except why can't I compare strings? It seems too
>useful when dealing with user input, or parsing messages or config
>>>> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
some_value = Weekdays.thu
user_input = raw_input("Enter day name")
if user_input == str(some_value):
>Additionaly, perhaps the call method of the enumeration object should
>construct a value from strings?
>>>> Weekdays.mon == Weekdays('mon')
Either way works for me.
TZOTZIOY, I speak England very best.
please stop spamming us."
More information about the Python-list