Decorating methods - where do my arguments go?

Michele Simionato michele.simionato at gmail.com
Mon May 11 14:37:59 CEST 2009


On May 8, 5:33 pm, Mikael Olofsson <mik... at isy.liu.se> wrote:

>  >>> class test_decorator(object):
> ...     def __init__(self,func):
> ...         self._func = func
> ...     def __call__(self, *args):
> ...         print 'Decorator:', args
> ...         self._func(*args)

Or you could use the decorator module (http://pypi.python.org/pypi/
decorator):

from decorator import decorator

@decorator
def test_decorator(func, *args, **kw):
   print 'Decorator:', args
   return func(*args)



More information about the Python-list mailing list