ITPub博客

首页 > 应用开发 > > Python学习-装饰器之函数的元数据

Python学习-装饰器之函数的元数据

作者:ybbyic 时间:2019-09-10 16:37:28 0 删除 编辑

[root@localhost /]# 

[root@localhost /]# 

[root@localhost /]# cat z.py 

#!/bin/python

from functools import update_wrapper, wraps

def a(b,c=3,d=[]):

        '''aaaaaaaaaaaaaa'''

    return a*2

#print a.__name__

#print a.__defaults__

#print a.__doc__

def zhu(func):

    @wraps(func)

    def zlg():

        '''bbbbbbbbbbbbb'''

        print 'cccccccccc'

        func()

    #update_wrapper(zlg,func)

    return zlg

@zhu

def haha():

    '''kkkkkkkkkkkkk'''

    print 'ffffffffffffffffff'

print haha.__doc__

print haha.__name__

[root@localhost /]# 

[root@localhost /]# 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1769/viewspace-3126195/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    88
  • 访问量
    1009