R
Roy Smith
If I have an enum, how can I verify that it's a legal value? Can I do:
Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
def foo (day):
if day not in Weekdays:
raise ValueError
Also, do enums have __dict__ slots? Can I do something like:
day = 'sun'
print Weekdays.__dict__[day]
Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
def foo (day):
if day not in Weekdays:
raise ValueError
Also, do enums have __dict__ slots? Can I do something like:
day = 'sun'
print Weekdays.__dict__[day]