Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: suggestions for functional style (singleton pattern?) Date: Sat, 28 Feb 2015 22:23:02 -0800 Organization: A noiseless patient Spider Lines: 7 Message-ID: <874mq58ce1.fsf@jester.gateway.pace.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="c694756f1077760bb5296aae16c74092"; logging-data="25281"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195MAnI/4PgjyWiuSg5ZDC6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:TBUJMsVT2VBU51haSUHDx4pCebE= sha1:JEGRxeJJMjt6meCJfWgqcZKVbvY= Xref: csiph.com comp.lang.python:86648 yves@zioup.com writes: > Are there better ways to address this? Any suggestion on this style? I guess I don't completely understand the question. But one way to do a singleton in python is put the initialization code into a separate module. Then the first time you import the module, the code runs, but it doesn't re-run on subsequent imports.