diff --git a/singleton.py b/singleton.py new file mode 100644 index 000000000..5a2516672 --- /dev/null +++ b/singleton.py @@ -0,0 +1,12 @@ +class Singleton(object): + ''' + Share single instance of this class, initially created one + ''' + instance = None + + def __new__(cls): + if Singleton.instance is not None: + return Singleton.instance + + Singleton.instance = object.__new__(cls) + return Singleton.instance