recipe-464407.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def __new__(typ, *args, **kw):
        #check the class has an __instances__ dict, if not, 
        #create it and initialize __instance_id.
        try:
            typ.__instances__
        except AttributeError:
            typ.__instance_id = 0
            typ.__instances__ = weakref.WeakValueDictionary()
        obj = object.__new__(typ, *args, **kw)
        obj.id = typ.__instance_id
        typ.__instances__[typ.__instance_id] = obj
        typ.__instance_id += 1
        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号