python单例的实现

2021-06-09 21:05

阅读:684

标签:not   war   bsp   pre   实现   __new__   super   python   new   

class CCP(object):
    def __new__(cls, *args, **kwargs):
        if not hasattr(cls, _instance):
            cls._instance = super(CCP, cls).__new__(cls, *args, **kwargs)
        return cls._instance

 

python单例的实现

标签:not   war   bsp   pre   实现   __new__   super   python   new   

原文地址:https://www.cnblogs.com/liuxuelin/p/14483561.html


评论


亲,登录后才可以留言!