James Stroud wrote: > The thread "why not arrays" got me thinking. I would really > like to inherit > from a list so that I can add methods based on its contents, > say if I filled > it with a type of object and wanted to iterate over all > objects. I have built > a wrapper around a list like this for general use: > > class list_of_objects: > def __init__(self): > self.data = [] > def __len__(self): > return len(self.data) > etc ... > > Then it can be heritable and I can add or override methods. > Why aren't built > in lists and dictionaries real heritable types that can save > this kind of patchwork?
They are since Python 2.2 (IIRC): class mylist(list): def mymethod(self): self.x = 5 ...etc. What problems are you running into? FuManChu -- http://mail.python.org/mailman/listinfo/python-list