What's wrong with this code snippet?

Karlo Lozovina _karlo_ at _mosor.net_
Wed Jan 4 17:19:27 EST 2006

Here is it:

class Human:
    def __init__(self, eye_one, eye_two):
        self.eye_one = eye_one
        self.eye_two = eye_two
class Population:
    def __init__(self):        
        self.house = []
        for i in range(0, POPULATION_COUNT):
    def GenerateRandomColour():
        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__
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 :(.

Any help greatly appriciated :).

 _______                                        Karlo Lozovina - Mosor
|   |   |.-----.-----.     web: http://www.mosor.net || ICQ#: 10667163
|       ||  _  |  _  |             Parce mihi domine quia Dalmata sum.

More information about the Python-list mailing list