2022-05-23 19:23:35 +08:00

18 lines
330 B
Python

from functools import wraps
def singleton(cls):
_instance = {}
@wraps(cls)
def inner(*args, **kargs):
if cls not in _instance:
_instance[cls] = cls(*args, **kargs)
cls.instance = _instance[cls]
return _instance[cls]
return inner
# Project.__name__
# Projec