11 lines
368 B
Python
11 lines
368 B
Python
'Demo Singleton Code von https://stackoverflow.com/a/6798042/9773263'
|
|
|
|
|
|
class Singleton(type):
|
|
'Singelton von agf, Lizenz: CC BY-SA 2.5'
|
|
_instances = {}
|
|
|
|
def __call__(cls, *args, **kwargs):
|
|
if cls not in cls._instances:
|
|
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
|
return cls._instances[cls]
|