On Sep 21, 7:15 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > 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
__getattr__ only works for attributes that don't exist. The name is sorta confusing...
-- http://mail.python.org/mailman/listinfo/python-list