Python Sigleton 模式

python单例模式(Sigleton)的实现,如下:

class Sigleton:

    __instance = None
    
    def __init__(self):
        pass
    
    def __new__(cls, *args, **kwd):
        if Sigleton.__instance is None:
            Sigleton.__instance = object.__new(cls, *args, **kwd)
        return Sigleton.__instance
posted @ 2011-02-24 18:51  Charliee  阅读(283)  评论(0编辑  收藏  举报