DeTechn Blog

手写一个单例

#python2
class A(object):
    __instance = None
    def __new__(cls,*args,**kwargs):
        if cls.__instance is None:
            cls.__instance = objecet.__new__(cls)
            return cls.__instance
        else:
            return cls.__instance

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »