Tekkaman

导航

 

[python's decorator&wrapper]

decorator

  A function returning another function, usually applied as a function transformation using the @wrapper syntax. Common examples for decorators are classmethod() andstaticmethod().

  The decorator syntax is merely syntactic sugar, the following two function definitions are semantically equivalent:

  

  The same concept exists for classes, but is less commonly used there.

udpate_wrapper: 把wrapped的属性值拷贝到wrapper

  

wraps: partial of udpae_wrapper

  

 how to use ?

  

参考:

1、http://docs.python.org/2.7/library/functools.html#functools.update_wrapper

2、http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318435599930270c0381a3b44db991cd6d858064ac0000

posted on 2013-11-29 18:32  Tekkaman  阅读(470)  评论(0编辑  收藏  举报