Re: Counting method calls

2007-09-21 Thread chris . monsanto
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

Counting method calls

2007-09-21 Thread Ricardo Aráoz
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