En Thu, 22 May 2008 12:20:56 -0300, inhahe <[EMAIL PROTECTED]> escribió:
> I thought about the fact that a decorator is merely syntactic sugar, so it > shouldn't have any closure magic that I can't make myself, and I realized > that I could have done it the following way: > > def makefunc(func): > def func2(instance, *args): > result = func(instance, *args) > instance.save() > return result > return func2 Using functools.wraps is better because it helps to preserve the function name and signature: def makefunc(func): @wraps(func) def wrapper(self, *args, **kwds): result = func(self, *args, **kwds) self.save() return result return wrapper -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list