src/so_magic/utils/singleton.py
__all__ = ['Singleton']
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
instance = cls._instances.get(cls)
if not instance:
instance = super(Singleton, cls).__call__(*args, **kwargs)
cls._instances[cls] = instance
return instance