Re: enum question

2005-03-09 Thread Terry Hancock
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,

Re: enum question

2005-03-05 Thread Carl Banks
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

Re: enum question

2005-03-05 Thread Patrick Useldinger
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

Re: enum question

2005-03-05 Thread Stephen Toledo-Brown
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

Re: enum question

2005-03-04 Thread Larry Bates
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

enum question

2005-03-04 Thread M.N.A.Smadi
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