Karlo Lozovina wrote: > Here is it:
> > class Population: > def __init__(self): > self.house = [] > for i in range(0, POPULATION_COUNT): > self.house.append(Human(self.GenerateRandomColour(), > self.GenerateRandomColour())) > > def GenerateRandomColour(): > rn.seed() > colour = rn.choice(['C', 'P', 'Z']) > return colour > --- > > Uppon running it gives this error: > > --- > Initializing first generation population: > Traceback (most recent call last): > File "population.py", line 38, in ? > earth = Population() > File "population.py", line 26, in __init__ > self.house.append(Human(self.GenerateRandomColour(), > self.GenerateRandomColour())) > TypeError: GenerateRandomColour() takes no arguments (1 given) > --- > > If I remove GenerateRandomColour from class definition, and put it as a > separate function, everything works fine. I've been staring at this code > for half an hour and can't find what's wrong :(. > Class methods must have at least the 'self' argument. So def GenerateRandomColour(self): *do something Gerard -- http://mail.python.org/mailman/listinfo/python-list