PEP 354 -- "in" operator?

Roy Smith roy at panix.com
Mon Feb 27 10:30:14 EST 2006


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]



More information about the Python-list mailing list