
Jan. 24, 2008
6:11 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)
And yes, there's also: wheres= Enum( UP= 0, DOWN= 0, LEFT= 0, RIGHT= 0 ) print UP, DOWN, LEFT, RIGHT print wheres.UP, wheres.DOWN, wheres.LEFT, wheres.RIGHT 2 0 3 1 2 0 3 1 and: wheres= Enum( 0, 'UP DOWN LEFT RIGHT'.split() ) print UP, DOWN, LEFT, RIGHT print wheres.UP, wheres.DOWN, wheres.LEFT, wheres.RIGHT 0 1 2 3 0 1 2 3