标签归档:Decorator

Charming Python: Decorators make magic easy

今天在看Python的Decorators,找到篇文章,写的很详细了,收藏下来。
Charming Python: Decorators make magic easy

David Mertz, Ph.D. (mertz@gnosis.cx), Developer, Gnosis Software, Inc.

29 Dec 2006

Python made metaprogramming possible, but each Python version has added slightly different — and not quite compatible — wrinkles to the way you accomplish metaprogramming tricks. Playing with first-class function objects has long been around, as have techniques for peaking and poking at magic attributes. With version 2.2, Python grew a custom metaclass mechanism that went a long way, but at the cost of melting users’ brains. More recently, with version 2.4, Python has grown “decorators,” which are the newest — and by far the most user-friendly way, so far — to perform most metaprogramming.

Doing a lot by doing very little 继续阅读

发表在 Python | 标签为 , | 留下评论