singleton ... again

Roy Smith roy at panix.com
Wed Feb 12 14:40:30 CET 2014


In article <mailman.6750.1392199807.18130.python-list at python.org>,
 Ben Finney <ben+python at benfinney.id.au> wrote:

> Gregory Ewing <greg.ewing at canterbury.ac.nz> writes:
> 
> > Roy Smith wrote:
> > > It looks to me like he's trying to implement a classic Gang of Four
> > > singleton pattern.
> >
> > Which I've never really seen the point of in Python, or any other
> > language for that matter. Just create one instance of the class during
> > initialisation, put it in a global somewhere, and use it thereafter.
> 
> Make that “somewhere” a module namespace, and you effectively have a
> Singleton for all practical purposes. So yes, I see the point of it; but
> we already have it built in :-)

This is one of the big problems with the Gang of Four book (and most of 
the pattern literature).  They present these patterns as universal to 
all OOPL's, when in reality, so much of them is "Things I need to do to 
appease the C++ compiler".



More information about the Python-list mailing list