Discuss / Python / 小结末问用递归走一条邪路

小结末问用递归走一条邪路

Topic source
import functools
def log(func):
    global text_of_log
    @functools.wraps(func)
    def wrapper(*arg,**kw):
        print('%sfunction name: %s'%(text_of_log, func.__name__))
        return func(*arg,**kw)
    if hasattr(func,'__call__'):
        text_of_log = ''
        return wrapper
    else:
        text_of_log = func+' '
        return log
    

有点问题,略过吧


  • 1

Reply