饿汉式单例模式实现预先加载,急切初始化,单例对象在类实例化前创建。
[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class Singleton( object ):
""" """
_instance = None
def __new__( cls , * args, * * kwargs):
if not hasattr (Singleton, '_instance' ):
|