摘要:
以下是一段通过metaclass实现Profiler的Python代码,很简单,功能不多,目的是为了展示Python的metaprogramming的能力,这种能力,无疑是很实用的,而且可以将AOP的方面(aspect)概念发挥的很好!下面的Profiler类(metaclass)就可以将方法的profiling在不同的类中复用。Code highlighting produced by Acti... 阅读全文
posted @ 2006-08-22 10:36
Cavingdeep
阅读(3292)
评论(4)
推荐(0)
摘要:
这里是一段Python代码,展示了如何利用metaclass来实现一个通用的Singleton,这使任何一个class都可以简单的复用这一行为:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--classSingleton(type):def__call... 阅读全文
posted @ 2006-08-22 10:34
Cavingdeep
阅读(2223)
评论(0)
推荐(0)