class Singleton(object): def __new__(type): if not '_the_instance' in type.__dict__: type._the_instance = object.__new__(type) return type._the_instance a=Singleton() a.toto = 12 b=Singleton() print b.toto print id(a),id(b) # the same !! print a print b ## now lets inherit from it: class Main(Singleton): def __init__(self): Singleton.__init__(self) ## only init if not done already #if not hasattr(self, "x"): # self.x =4 test = Main() print test #print test.x test.x = 5 print test.x test2 = Main() print test2 print test2.x