singleton in python ?

JohnO jo at johnochiltree.uklinux.net
Mon May 6 03:58:04 EDT 2002


fritz steindl (-:fs) wrote:

> hi,
> 
> what is the best way to implement a singleton in python ???
> 
> ( class that allows only _one_ instantiation - like java singletons)
> 
> i miss static variables and functions in python (or i don't see them :-)
> 
> <thx>
> 
> fritz
> (-:fs)

Hi,
An excellent discussion (at least I found it so :) of patterns in python 
can be found in Thomas Christopher's book, "Python Programming Patterns" 
(see: http://ppp.toolsofcomputing.com )

Also there's a "borg" type of singleton on Active State's Python Cookbook ( 
http://aspn.activestate.com/ASPN/Cookbook/ )

John Ochiltree



More information about the Python-list mailing list