从无法访问的项目Fork
体验新版 GitCode,发现更多精彩内容 >>
from functools import wraps def singleton(cls): instances = {} @wraps(cls) def getinstance(*args, **kw): if cls not in instances: instances[cls] = cls(*args, **kw) return instances[cls] return getinstance