MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / getinstance

Function getinstance

Target Offer/Singleton.py:67–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65def singleton(cls, *args, **kwargs):
66 instances = {}
67 def getinstance():
68 if cls not in instances:
69 instances[cls] = cls(*args, **kwargs)
70 return instances[cls]
71 return getinstance
72@singleton
73class MyClass3(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected