Hello,
I'm trying to generate two classes, one of them is a given object and
the other is a 'factory' of those objects. I'm doing this because I'm
working with huge amounts of objects and would like to have a loop
generating them. The problem is that I fear that my understanding of OOP
is just not good enough. So what do you say, is this a good way to solve
this??
class objct:
def __init__(self, name, val):
self.name = name
self.val = val
class collection:
def __init__(self, objcts):
objecList = []
for i in range(objcts):
instance = 'myInst%i' %(i)
objecList.append(instance)
for i in range(objcts):
i = objct(objecList[i], i)
print i.name
print i.val
myC = collection(10)
Regards,
Carlos
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor