首页 > 编程语言 > 详细

Python单例实现

时间:2014-12-29 10:21:40      阅读:233      评论:0      收藏:0      [点我收藏+]

Python 单例模式:

class Singleton(object):
    def __new__(cls, *args, **kw):
        if not hasattr(cls, _instance):
            orig = super(Singleton, cls)
            cls._instance = orig.__new__(cls, *args, **kw)
        return cls._instance

 

Python单例实现

原文:http://www.cnblogs.com/hangshi/p/4191108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!