singleton ... again

Ben Finney ben+python at benfinney.id.au
Wed Feb 12 05:09:25 EST 2014


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 :-)

-- 
 \     “To save the world requires faith and courage: faith in reason, |
  `\            and courage to proclaim what reason shows to be true.” |
_o__)                                                —Bertrand Russell |
Ben Finney




More information about the Python-list mailing list