class MyList(list): Is this ok?

Christopher T King squirrel at WPI.EDU
Tue Jul 6 09:14:57 EDT 2004


On Tue, 6 Jul 2004, Martin Bless wrote:

> import csv,sys
> 
> class ColumnCollector(list):
> 
>     def __init__(self):
>         self.sums = []
>         list.__init__(self)         #1

This is perfectly acceptable, though the new-style way to do this is with 
the slightly messier line:
          super(ColumnCollector,self).__init__()

>     def append(self, v, calc=None):
>         list.append(self,v)         #2

Same applies here:
          super(ColumnCollector,self).append(v)

What you have now though is effectively the same thing as using the 
super() calls.




More information about the Python-list mailing list