
Jan. 24, 2008
5:55 a.m.
What I usually do in Python is this:
ERROR, OK, ALSO_OK = range(-1, -1 + 3)
Start and stop values, as well step sizes other than one, are easily achieved. Skipping values is done like this:
ERROR, OK, ALSO_OK, SOMEOTHER, LAST = range(-1, -1 + 3) + range(1000, 1000 + 2)
Crazy: wheres= Enum() wheres.UP wheres.DOWN wheres.LEFT wheres.close() print UP, DOWN, LEFT, RIGHT 0 1 2 3 Crazier: wheres= Enum() while wheres.open: with wheres: UP, DOWN, LEFT, RIGHT print UP, DOWN, LEFT, RIGHT 0 1 2 3