Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: singleton ... again Date: Wed, 12 Feb 2014 23:04:32 +1300 Lines: 15 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net M5S+e6lw2g8BMbM1E2lDLQ7/l+DRAKPrpMnyVx2+CgS9sgrxUt Cancel-Lock: sha1:8FCGVq8VQP6YeKmyiTmufz2QiMc= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:66022 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. If you really want to make sure nobody creates another instance by accident, delete the class out of the namespace after instantiating it. -- Greg