我已经写了一大段代码,我希望改进我的详细输出。我有一个if verbose: print '**** function_name ****'
在函数开头和结尾的想法,甚至定义了一个函数以使其更容易调用(我在这里使用 kindall 编写的非常性感的详细打印)
def verbwrap(function, side):
if side=='start':
verboseprint(' ****** %s ******' %(function))
if side=='end':
verboseprint(' ^^^^^^ %s ^^^^^^' %(function))
打算像这样使用它:
import inspect
def test(lst):
verbwrap(inspect.currentframe().f_code.co_name,'start')
for i in lst:
print i
verbwrap('test', 'end') #equivalent to above, but easier to write :(
有没有办法让我只调用一次重做verbwrap()
一次?再多的修补也没有让我找到答案!