This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
producer/singleton.py

31 lines
632 B
Python

#!/usr/bin/env python
"""
Singleton meta module
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
__module_name__ = "singleton"
__version__text__ = "1"
class Singleton(object):
"""
Singleton metaclass
"""
_instances = {}
def __new__(class_, *args, **kwargs):
"""
New
:param args:
:param kwargs:
:return:
"""
if class_ not in class_._instances:
class_._instances[class_] = super(
Singleton, class_).__new__(
class_, *args, **kwargs)
return class_._instances[class_]