MCPcopy Create free account
hub / github.com/SpaceNetLab/StarryNet / Singleton

Class Singleton

starrynet/log.py:58–72  ·  view source on GitHub ↗

Singleton pattern from Wikipedia See http://en.wikipedia.org/wiki/Singleton_Pattern Intended to be used as a __metaclass_ param, as shown for the class below.

Source from the content-addressed store, hash-verified

56
57
58class Singleton(type):
59 """Singleton pattern from Wikipedia
60 See http://en.wikipedia.org/wiki/Singleton_Pattern
61
62 Intended to be used as a __metaclass_ param, as shown for the class
63 below."""
64
65 def __init__(cls, name, bases, dict_):
66 super(Singleton, cls).__init__(name, bases, dict_)
67 cls.instance = None
68
69 def __call__(cls, *args, **kw):
70 if cls.instance is None:
71 cls.instance = super(Singleton, cls).__call__(*args, **kw)
72 return cls.instance
73
74
75class StarrynetLogger(Logger, object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected