I'd like this class to act like a list. It's data resides in the attribute self.data.
If I have an instance, pp = population, does defining __getitem__ mean I can refer to
pp instead of pp.data? Or is it the defining of __repr__ that does that?
Would deriving this class from list instead of object provide me with 'pop'.
Right now I need to implement 'pop'method. Thanks
class population (object):
def __init__ (self):
self.data = []
def append(self, item):
self.data.append(item)
def extend(self, item):
self.data.extend(item)
def sort(self):
self.data.sort(cmp=fitnesscompare)
def __getitem__(self, index): return self.data[index]
def __setitem__(self, index, item): self.data[index] = item
def __len__(self): return len(self.data)
def __repr__(self): return repr(self.data)
def copy(self):
return copy.deepcopy(self)