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,
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
On Dec 21, 1:32 am, "Chris Rebert" wrote:
> On Sat, Dec 20, 2008 at 11:12 PM, Piyush Anonymous
>
> 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 t
On Sat, Dec 20, 2008 at 11:12 PM, Piyush Anonymous
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 decorator for all the
> method
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.
---
http://codepad.org/2w7JVvDB