概念自解

单例模式

2017-10-26  本文已影响0人  bigpangl
推荐阅读:

1 单例模式 | 百度百科
2 单例模式的优缺点和使用场景 | 博客园
3 为什么要用单例模式 | 博客园
4 单例模式 | 菜鸟教程

python实现
class Singleton(object):
    __instance = None
    def __new__(cls,*args,**kwd):
        if cls.__instance is None:
            cls.__instance = object.__new__(cls,*args,**kwd)
        return cls.__instance
上一篇 下一篇

猜你喜欢

热点阅读