#!/usr/bin/env python
# -*- coding: utf-8 -*-
import functools
def wrapmethod(f):
@functools.wraps(f)
def wrap(*args, **kwargs):
print '>> %s' % (f.func_name)
# Here I'll do pre-processing
r = f(*args, **kwargs)
# Here I'll do post-processing
return r
return wrap
@wrapmethod
def foo():
pass
class Test(object):
@wrapmethod
def foo(self):
pass
test = Test()
test.foo()
foo()