S
Stevie_mac
I need to have a static class data member like c (see semi pseudo-like code below). How can I achieve this?
class object
static _ID
_ID = _ID + 1
self.ID = _ID
class group
. . .
def AddObject(self,obj)
objs.append(obj)
def GetObject(self,iWhich)
return objs[iWhich]
g = group()
o1=object() #gets ID of 1
o2=object() #gets ID of 2
o3=object() #gets ID of 3
g.append(o2) #store object with ID of 2
g.append(o3) #store object with ID of 3
g.append(o1) #store object with ID of 1
print g.GetObject(0).ID #print ID of group object 0
print g.GetObject(1).ID #print ID of group object 1
print g.GetObject(2).ID #print ID of group object 2
obviously this code is duff, its the solution I need.
Cheers Stevie_Mac.
class object
static _ID
_ID = _ID + 1
self.ID = _ID
class group
. . .
def AddObject(self,obj)
objs.append(obj)
def GetObject(self,iWhich)
return objs[iWhich]
g = group()
o1=object() #gets ID of 1
o2=object() #gets ID of 2
o3=object() #gets ID of 3
g.append(o2) #store object with ID of 2
g.append(o3) #store object with ID of 3
g.append(o1) #store object with ID of 1
print g.GetObject(0).ID #print ID of group object 0
print g.GetObject(1).ID #print ID of group object 1
print g.GetObject(2).ID #print ID of group object 2
obviously this code is duff, its the solution I need.
Cheers Stevie_Mac.