Decorator in Python (1)
来源:互联网 发布:浴缸推荐 知乎 编辑:程序博客网 时间:2024/06/06 09:51
def zhuang(F):
print 'in zhuang... F = ', F
def wraper(*args):
F(args)
print 'after zhuang...', wraper
return wraper
@zhuang
def func(*args):
print 'in func...', args
class C:
@zhuang
def func(*args):
print 'in c.func..'
print 'func = ', func
print 'args[0] = ',args[0]
func(1, 3, 4)
cins = C()
cins.func(1,3,6)
print 'Instance = ',cins
---------------------Output-------------------------
in zhuang... F = <function func at 0x012135F0>
after zhuang... <function wraper at 0x01229F70>
in zhuang... F = <function func at 0x0122E030>
after zhuang... <function wraper at 0x0122E070>
in func... ((1, 3, 4),)
in c.func..
func = <function wraper at 0x01229F70>
args[0] = (<__main__.C instance at 0x0122C3A0>, 1, 3, 6)
Instance = <__main__.C instance at 0x0122C3A0>
- Decorator in Python (1)
- Decorator in Python
- Python decorator 1: 函数
- The analysis of decorator in Python
- python decorator
- python decorator
- python decorator
- python decorator
- Python - Decorator
- Python decorator
- python decorator
- python decorator
- Python Decorator
- Python Decorator
- python decorator
- Python Decorator
- python decorator
- Python - decorator
- 文件上传 file submit button
- Installing SVN server in Windows OS.
- C#日期格式化
- CLOUD COMPUTING (1)
- Android中如何实现高亮显示即选中状态
- Decorator in Python (1)
- ping命令查看对方操作系统
- js 闭包
- 连接不到cn.archive.ubuntu.com时,重新配置源。
- SET QUOTED IDENTIFIER ON|OFF用法
- C#获取当前IE的URL
- 图片
- 事务隔离级别示例与分析(二)
- 用javap分析java编译器对string常量表达式的处理和优化