码迷,mamicode.com
首页 > 编程语言 > 详细

python装饰器(3)

时间:2017-09-02 20:04:12      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:python装饰器   col   python   嵌套   auth   turn   author   nbsp   def   

另一种实现方式:

 1 __author__ = "csy"
 2 
 3 def test2(func):
 4     def test1():
 5         func()
 6         print(func)
 7     return test1
 8 
 9 def bar2():
10     print(in the bar2)
11 
12 bar2 = test2(bar2)    # test2将bar2作为变量在嵌套函数test1中调用,再将test1的内存地址作为返回值重新赋给bar2
13 bar2()

 

python装饰器(3)

标签:python装饰器   col   python   嵌套   auth   turn   author   nbsp   def   

原文地址:http://www.cnblogs.com/csy113/p/7467358.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!