pylab_ml.common.singleton.singleton

singleton(cls)[source]

Create Singleton by decorator

Pros

Decorators are additive in a way that is often more intuitive than multiple inheritance.

Cons

While objects created using MyClass() would be true singleton objects, MyClass itself is a a function, not a class, so you cannot call class methods from it. Also for m = MyClass(); n = MyClass(); o = type(n)(); then m == n && m != o && n != o