enum question

Carl Banks invalidemail at aerojockey.com
Sat Mar 5 14:08:05 EST 2005


M.N.A.Smadi wrote:
> does python support a C-like enum statement where one can define a
> variable with prespesified range of values?

The thing is, variables don't have types; objects do.  A variable can
be bound to an object of any type, so there's no way to prespecify a
range of values for a variable.

Your question has the air of someone who's evaluating Python features,
considering whether to try it.  If so, you might need to widen your
worldview a little to understand Python; its variables are
fundamentally different from C, and things like enums don't make much
sense in Python because of it.  However, Python is versatile enough
that you can get something to that effect if you really need it.


-- 
CARL BANKS




More information about the Python-list mailing list