On Friday 04 March 2005 02:54 pm, M.N.A.Smadi wrote:
> does python support a C-like enum statement where one can define a
> variable with prespesified range of values?
No, but in most situations where I would've used an enum, I use a
trivial class like this:
class states:
ON, OFF, UNKNOWN,
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 va
M.N.A.Smadi wrote:
does python support a C-like enum statement where one can define a
variable with prespesified range of values?
thanks
m.smadi
>>> BLUE, RED, GREEN = 1,5,8
>>> BLUE
1
>>> RED
5
>>> GREEN
8
--
http://mail.python.org/mailman/listinfo/python-list
M.N.A.Smadi wrote:
does python support a C-like enum statement where one can define a
variable with prespesified range of values?
Not built in, but there are various solutions available, some simpler
than others. See the Infrequently Asked Questions:
http://www.norvig.com/python-iaq.html
--
Ste
Not completely sure I understand (my C is weak).
But you can do:
x=range(9)
x's contents will be
[0,1,2,3,4,5,6,7,8]
or
x=range(12,25)
x's conetnst will be
[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
if you mean a way to limit x's contents to a predefined
list of values, you need to
does python support a C-like enum statement where one can define a
variable with prespesified range of values?
thanks
m.smadi
--
http://mail.python.org/mailman/listinfo/python-list