T
Thomas Nelson
My code:
class Policy(list):
def __cmp__(self,other):
return cmp(self.fitness,other.fitness)
j = Policy()
j.fitness = 3
k = Policy()
k.fitness = 1
l = Policy()
l.fitness = 5
print max([j,k,l]).fitness
prints 3, when I was expecting it to print 5. What have I done wrong?
Thanks for the help,
THN
class Policy(list):
def __cmp__(self,other):
return cmp(self.fitness,other.fitness)
j = Policy()
j.fitness = 3
k = Policy()
k.fitness = 1
l = Policy()
l.fitness = 5
print max([j,k,l]).fitness
prints 3, when I was expecting it to print 5. What have I done wrong?
Thanks for the help,
THN