Gary Herron <[EMAIL PROTECTED]> writes:
> Another similar approach that keeps those values together in a single
> namespace is this (my favorite):
>
> class State:
> OPENED, CLOSED, ERROR = range(3)
>
> Then you can refer to the values as
> State.OPENED
> State.CLOSED
> State.ERROR
Of course, with this solution you still get this problem:
class State:
OPENED, CLOSED, ERROR = range(3)
class Spam:
EGGS, HAM, TOAST = range(3)
State.ERROR == Spam.TOAST => True
Thus, the solutions using unique objects for each value seems cleaner,
and closer to actual symbols, to me.
I don't see why Python doesn't go all the way and add a real symbol
type, though. I've seen way too many ugly string or integer based
solutions.
--
Björn Lindström <[EMAIL PROTECTED]>
Student of computational linguistics, Uppsala University, Sweden
--
http://mail.python.org/mailman/listinfo/python-list