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

Method __new__

Target Offer/Singleton.py:12–16  ·  view source on GitHub ↗
(cls, *args, **kwargs)

Source from the content-addressed store, hash-verified

10'''
11class Singleton1(object):
12 def __new__(cls, *args, **kwargs):
13 if not hasattr(cls, '_instance'):
14 orig = super(Singleton1, cls)
15 cls._instance = orig.__new__(cls, *args, **kwargs)
16 return cls._instance
17
18class Myclass(Singleton1):
19 a = 1

Callers

nothing calls this directly

Calls 1

__new__Method · 0.45

Tested by

no test coverage detected