10 lines
211 B
Python
Raw Permalink Normal View History

2021-08-30 14:33:18 +08:00
def Singleton(cls):
_instance = {}
def _singleton(*args, **kargs):
if cls not in _instance:
_instance[cls] = cls(*args, **kargs)
return _instance[cls]
return _singleton