Files
2022-08-12 03:40:35 -05:00

18 lines
453 B
Python

from abc import ABCMeta
from typing import Any
class Singleton(ABCMeta):
"""
This class is a standard implementation of the Single Pattern
(Note: Has not been tested for Thread Saftey)
"""
_instances = {}
def __call__(cls, *args, **kwargs) -> Any:
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]