Can not think of what has been a good way to write in python a perfect Singleton, reference a lot of
examples , came up with such an approach.
class Singleton(object): __instance = None def __new__(classtype, *args, **kwargs): if classtype != type(classtype.__instance): classtype.__instance = object.__new__(classtype, *args, **kwargs) classtype.__instance.init() return classtype.__instance def init(self): pass

No Responses to “Singleton on the python”