A simple array in Python
Paul McGuire
ptmcg at austin.rr._bogus_.com
Tue Jan 9 07:11:25 EST 2007
<bg_ie at yahoo.com> wrote in message
news:1168337391.770307.54750 at 11g2000cwr.googlegroups.com...
> Hi,
>
> I have the following enum -
>
> class State:
> Fire = 0
> Water = 1
> Earth = 2
>
> And I want a variable which holds a value for each of these states,
> something like -
>
> myState1[State.Fire] = 10
> myState1[State.Earth] = 4
>
> myState2[State.Fire] = 20
> myState2[State.Earth] = 24
>
> How do I do this?
>
> Thanks Barry.
>
How about (arrays are sooo last century):
class State(object):
def __init__(self,**kwargs):
self.__dict__.update(kwargs)
myState1 = State(Fire=10, Earth=4)
myState2 = State(Fire=20, Earth=24)
print myState1.Fire
print myState2.Earth
-- Paul
More information about the Python-list
mailing list