added setup.py

created creational package
moved singleton into its own python file
This commit is contained in:
tylerlaberge
2016-07-18 11:19:44 -04:00
parent 62fb22a3b2
commit 2811f40da8
4 changed files with 12 additions and 1 deletions
View File
+16
View File
@@ -0,0 +1,16 @@
class Singleton(type):
"""
Singleton Metaclass.
Enforces any object using this metaclass to only create a single instance.
"""
__instance = None
def __call__(cls, *args, **kwargs):
"""
Override the __call__ method to make sure only one instance is created.
"""
if cls.__instance is None:
cls.__instance = type.__call__(cls, *args, **kwargs)
return cls.__instance