What do you use as symbols for Python ?

Erik Max Francis max at alcyone.com
Thu Nov 10 02:40:59 EST 2005


Pierre Barbier de Reuille wrote:

> When you need some symbols in your program, what do you use in Python ?
> 
> For example, an object get a state. This state is more readable if
> expressed as a symbols, for example "opened", "closed", "error".
> Typically, in C or C++, I would use an enum for that:
> enum OBJECT_STATE
> {
>   opened, closed, error
> }

	OPENED, CLOSED, ERROR = range(3)

	object.state = OPENED

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Whoever named it necking was a poor judge of anatomy.
   -- Groucho Marx



More information about the Python-list mailing list