Discuss / Python / 简单写一下

简单写一下

Topic source

def log(u): def dec(func): def wap(*p): print '%s start %s' %(u,p) f=func(p) print '%s end !!!'% p return f return wap

    if not callable(u):

            return dec
    else:
            return dec(u)

@log def new(t):

    print '%s running ...'% t

    return 'success'

new('thread1')


  • 1

Reply