If you are using Python 2.5, you can use functools.update_wrapper to
simplify your life. For instance

from functools import update_wrapper # requires Python 2.5

def trace(func):
    def wrapper(*args,**kw):
        print 'calling %s with args %s' % (func.__name__,args)
        return func(*args,**kw)
    return update_wrapper(wrapper,func)

class P(object):
    @classmethod
    @trace
    def c(cls):
        print cls

p =P()
p.c()

Also, you can have a look to my own decorator module:
http://www.phyast.pitt.edu/~micheles/python/decorator.zip


HTH,
            Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to