Re: [Tutor] Counting method calls

2007-09-23 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Kent Johnson wrote: >>> One more reference: >>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 >>> >>> This appears as recipe 6.6 in the second edition of the printed >>> cookbook. >>> >>> Kent >> >> Thanks Kent. I guess I got into deep

Re: [Tutor] Counting method calls

2007-09-23 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> One more reference: >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 >> >> This appears as recipe 6.6 in the second edition of the printed cookbook. >> >> Kent > > Thanks Kent. I guess I got into deep waters. > It's a shame though that

Re: [Tutor] Counting method calls

2007-09-23 Thread Daniel Kavic
Ok I have been a multimedia major for a few years now. I have tried javascript and that was bad, Java is just too difficult, so I joined this mailing list a while back. I have been frustrated because I just don't get entirely how OOProgramming works and how to actually write the stuff corre

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > One more reference: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 > > This appears as recipe 6.6 in the second edition of the printed cookbook. > > Kent Thanks Kent. I guess I got into deep waters. It's a shame though that you can not do this in a simple

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
One more reference: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 This appears as recipe 6.6 in the second edition of the printed cookbook. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> What version of Python are you using? When I try this program it prints > > Py 0.9.5 > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit > (Intel)] on win32 > > I thought it might be you were trying the class with the list init call >

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Hi, I'm trying to count method calls. Tried this but... >> class MyList(list): >>> ... def __init__(self): >>> ... self.calls = 0 ... snipped . > I think this does what you want. Notice that it doesn't have anything > special to do

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Hi, I'm trying to count method calls. Tried this but... >> class MyList(list): >>> ... def __init__(self): >>> ... self.calls = 0 > > should call list.__init__(self) here. Foolish me. > >>> ... def __getattr__(self, name): >>> ..

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
Ricardo Aráoz wrote: > Hi, I'm trying to count method calls. Tried this but... > class MyList(list): >> ... def __init__(self): >> ... self.calls = 0 should call list.__init__(self) here. >> ... def __getattr__(self, name): >> ... self.calls += 1 >> ... return