Singleton in Python Cookbook

Diez B. Roggisch deets at
Thu Jul 26 00:09:32 CEST 2007

Alex Popescu schrieb:
> Hi all!
> I was reading through Python Cookbook the Singleton recipe. At this moment 
> I am a bit puzzled as the example in the book is not working resulting in:
> TypeError: type.__new__(SingleSpam): SingleSpam is not a subtype of type
> (I haven't presented the original code as I am not sure about copyrights).

AFAIK the cookbook is completely found online at ASPN. So no sweat 
publishing it here.

And regarding the problem: is it possible that you forgot to subclass 
SingleSpam from object?


More information about the Python-list mailing list