f.py
#!/usr/bin/env python#encoding: utf8import sys, osreload(sys)sys.setdefaultencoding('utf-8')def outer(f): print 'some message com from outer function' def inner(*arg): print 'before function' f(3, 6) print 'after function' return inner@outerdef func(a, b): print func.__name__ print 'a = %s, b = %s' % (a, b)if __name__ == '__main__': print 'start' func() print 'end'
运行:
./f.py some message com from outer functionafter functionstartbefore functioninnera = 3, b = 6end