[Tutor] Python Version of "enum" ?
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Thu Oct 21 23:43:18 CEST 2004
On Thu, 21 Oct 2004, Gooch, John wrote:
> Is there an equivalent of C++'s 'enum' keyword to set a number of named
> constants ( like so )
> enum {
> OFF,
> ON,
> UNKNOWN
> };
>
> in Python? It makes reading the code a lot simpler, as opposed to having
> to look up what a status of "1" means, it can be replaced with "ON",
> which is much easier to understand.
Hi John,
Peter Norvig has written an answer for this infrequently answered
question. *grin* Here you go:
http://www.norvig.com/python-iaq.html
I hope this helps!
More information about the Tutor
mailing list