摘要:
#!/usr/bin/env python#coding:utf-8class Borg(object): _share_state = {} def __init__ (self): ''' 将__dict__和_share_state指向了同一个地址 这样会使_share_state的内容始终保持与__dict__同步 由于_share_state是类变量,最终就可以实现多个实例的__dict__保持同步的效果 ''' self.__dict__ = self._share_stateclass... 阅读全文
摘要:
可以使用id>>> print id.__doc__id(object) -> integerReturn the identity of an object. This is guaranteed to be unique amongsimultaneously existing objects. (Hint: it's the object's memory address.)>>> 阅读全文
摘要:
1、闭包(closure)2、装饰器(decorator)3、元类(metaclass)4、对象模型5、其它:new和init、作用域、传值和传引用、super 阅读全文