Re: trapping all method calls in a class...

2008-12-21 Thread Aaron Brady
On Dec 21, 1:32 am, Chris Rebert c...@rebertia.com wrote: On Sat, Dec 20, 2008 at 11:12 PM, Piyush Anonymous piyush.subscript...@gmail.com wrote: hi, i need to trap all method calls in a class in order to update a counter which is increased whenever a method is called and decreased

Re: trapping all method calls in a class...

2008-12-21 Thread Bruno Desthuilliers
Chris Rebert a écrit : (snip) Sidenotes about your code: - `args` and `kwds` are the conventional names for the * and ** special arguments for '**', the most conventional names (at least the one I usually see) are 'kwargs', then 'kw' -- http://mail.python.org/mailman/listinfo/python-list

Re: trapping all method calls in a class...

2008-12-21 Thread MrJean1
The decorate_meths() function as given fails: TypeError: 'dictproxy' object does not support item assignment But this version avoids that error (on Python 2.2 thru 2.6): def decorate_meths(klass): for nam, val in klass.__dict__.items(): if callable(val): setattr(klass,

trapping all method calls in a class...

2008-12-20 Thread Piyush Anonymous
hi, i need to trap all method calls in a class in order to update a counter which is increased whenever a method is called and decreased whenever method returns. in order to that i am trying to write a decorator for all the methods. see the code here with error. ---

Re: trapping all method calls in a class...

2008-12-20 Thread Chris Rebert
On Sat, Dec 20, 2008 at 11:12 PM, Piyush Anonymous piyush.subscript...@gmail.com wrote: hi, i need to trap all method calls in a class in order to update a counter which is increased whenever a method is called and decreased whenever method returns. in order to that i am trying to write a