Hi, I know I'm being dumb but, why does it not work?

>>> class MyList(list):
...     def __init__(self):
...         self.calls = 0
...     def __getattr__(self, name):
...         self.calls += 1
...         return list.__getattribute__(self, name)

>>> a = MyList()
>>> a
[]
>>> a.append(1)
>>> a
[1]
>>> a.calls
88
>>> a.append(3)
>>> a.calls
88
>>> a.sort()
>>> a
[1, 3]
>>> a.calls
176


TIA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to