singleton ... again

Tim Delaney timothy.c.delaney at gmail.com
Thu Feb 13 20:16:10 CET 2014


On 13 February 2014 20:00, Piet van Oostrum <piet at vanoostrum.org> wrote:

> Ben Finney <ben+python at benfinney.id.au> writes:
> > 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 :-)
>
> There is a use case for a singleton class: when creating the singleton
> object takes considerable resources and you don't need it always in your
> program.
>

Then have that resource in its own module, and import that module only when
needed e.g. inside a function. Python already has the machinery - no need
to reinvent the wheel.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140214/2a1a7d3a/attachment.html>


More information about the Python-list mailing list