[Tutor] Python Version of "enum" ?

Gooch, John John.Gooch at echostar.com
Thu Oct 21 22:47:12 CEST 2004


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. 

If not, can you declare named constants another way? Perhaps 'const MONDAY =
1', for example. 

Thank You, 
 

John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO  80112
Desk: 720-514-5708 


More information about the Tutor mailing list