Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: singleton ... again Date: Thu, 13 Feb 2014 10:57:02 +1300 Lines: 35 Message-ID: References: <9785668d-6bea-4382-8a0c-c1258f2e2693@googlegroups.com> <9b4cd207-5485-43b2-b67a-520ef4a50075@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net fw5Xct1dcdDMbELv1k7tPQIi3yuxi0ruVKgEc1OfLy7zeQsswS Cancel-Lock: sha1:fGgz/hTTHSCJMpSXS6ZtA9K+vXM= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: <9b4cd207-5485-43b2-b67a-520ef4a50075@googlegroups.com> Xref: csiph.com comp.lang.python:66102 Asaf Las wrote: > There is another one. > Once object passes through singletonizator > there wont be any other object than first one. > > Then object constructor can freely be used in every place > of code. You're still making things far more complicated than they need to be. *Why* do you want to be able to use the object constructor, instead of just using the prebuilt instance? If you want to hide the distinction between using call syntax and just accessing a global, then export a function that returns the global instance. That function can even lazily create the instance the first time it's called. That's a pattern that *is* useful, and I've often used in Python and other languages. E.g. _the_whatsit = None def get_whatsit(): if _the_whatsit is None: _the_whatsit = Whatsit() return _the_whatsit -- Greg