Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python': 0.11; 'class:': 0.16; 'finney': 0.16; 'it;': 0.16; 'namespace,': 0.16; 'reinvent': 0.16; 'singleton': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'creating': 0.23; 'module,': 0.24; '>': 0.26; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'writes:': 0.31; 'to:name:python-list': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'ben': 0.38; 'e.g.': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'resource': 0.38; 'to:addr:python.org': 0.39; 'skip:\xe2 10': 0.65; 'effectively': 0.66; '8bit%:40': 0.68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Bvo1GnquhsESbXicDKoLzNLMasx/5X9GGSYl2lpOQlU=; b=N/8GrCKIzYO35bePDsNtkIvBoqzcsVUMfF2UoDZyBdJUmKFpdGpDqRoCHcP8SguuXJ SC5pQ93Kt36JfywTXxRiHg8sf8w6//C7rqMu+01qePPI0qxZyRe0YMR6c+0wW0rnO6Sa Q0kpfu7znPxjuSftgKg9ioDRlcnHpXUcl2OJstjqdUwNEYRgkkWjUm98HGi6DERDUOYH 6u95Uact5nmy53X07sWDWCat8PCqF9dtZU0xUxD6neheAOi7LAn0lKyyMgBGeRl/w3bo r83DADQrTwqN7vbEGjNasUNfZRQ84dJbLkNYLB6VGUDL41yUcYCGTmK/WiMMVAfZ0bCL yd/A== MIME-Version: 1.0 X-Received: by 10.182.22.33 with SMTP id a1mr2667178obf.60.1392318970573; Thu, 13 Feb 2014 11:16:10 -0800 (PST) In-Reply-To: References: Date: Fri, 14 Feb 2014 06:16:10 +1100 Subject: Re: singleton ... again From: Tim Delaney To: Python-List Content-Type: multipart/alternative; boundary=001a1133177ca7bef204f24e8572 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392318974 news.xs4all.nl 2878 [2001:888:2000:d::a6]:45475 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66207 --001a1133177ca7bef204f24e8572 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 13 February 2014 20:00, Piet van Oostrum wrote: > Ben Finney writes: > > Make that =E2=80=9Csomewhere=E2=80=9D a module namespace, and you effec= tively have a > > Singleton for all practical purposes. So yes, I see the point of it; bu= t > > 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 --001a1133177ca7bef204f24e8572 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 1= 3 February 2014 20:00, Piet van Oostrum <piet@vanoostrum.org> wrote:
Ben Finney <ben+python@benfinney.id.au> writes:
> Make that =E2=80=9Csomewhere=E2=80=9D a module namespa= ce, and you effectively have a
> Singleton for all practical purposes. So yes, I see the point of it; b= ut
> we already have it built in :-)

There is a use case for a singleton class: when creating the singleto= n
object takes considerable resources and you don't need it always in you= r
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=C2=A0
--001a1133177ca7bef204f24e8572--