🌟 Re-add all project files.

This commit is contained in:
Robert Honz
2023-12-19 23:58:57 +01:00
parent 82a8fe96aa
commit 0d4a9d6b87
42 changed files with 6762 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
class SingletonMeta(type):
"""
The Singleton class can be implemented in different ways in Python. Some
possible methods include: base class, decorator, metaclass. We will use the
metaclass because it is best suited for this purpose.
"""
_instances = {}
def __call__(cls, *args, **kwargs):
"""
Possible changes to the value of the `__init__` argument do not affect
the returned instance.
"""
if cls not in cls._instances:
instance = super().__call__(*args, **kwargs)
cls._instances[cls] = instance
return cls._instances[cls]