[Tutor] class attribute to initiate more classes

Michiel Overtoom motoom at xs4all.nl
Sat Oct 31 06:43:53 CET 2009


On 31 Oct 2009, at 06:01 , Vincent Davis wrote:

> I hope this makes sense, I am sure there is a term for what I am  
> trying to do but I don't know it.

What a strange program. But at least it compiles:

import random

class people:
     def __init__(self, size):
         self.size = size

class makepeople:
     def __init__(self, randomsize):
         self.rsize = randomsize
         self.allpeople = []
     def makethem(self):
         for x in range(self.rsize):
             self.allpeople.append(people(self.rsize))

listofp = makepeople(int(random.gauss(100, 2)))
listofp.makethem()




More information about the Tutor mailing list