what is the difference between commenting and uncommenting the __init__ method in this class?
davea at davea.name
Tue Jan 29 03:19:50 CET 2013
On 01/28/2013 09:09 PM, iMath wrote:
> what is the difference between commenting and uncommenting the __init__ method in this class?
> class CounterList(list):
> counter = 0
> ## def __init__(self, *args):
> ## super(CounterList, self).__init__(*args)
> def __getitem__(self, index):
> self.__class__.counter += 1
> return super(CounterList, self).__getitem__(index)
If you don't call the super-class' __init__() method, then the list
won't take anyparameters. So the list will be empty,
More information about the Python-list