Deutsch   English   Français   Italiano  
<singletons-20231004125510@ram.dialup.fu-berlin.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: eternal-september.org!news.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: type annotation vs working code
Date: 4 Oct 2023 11:56:50 GMT
Organization: Stefan Ram
Lines: 21
Expires: 1 Sep 2024 11:59:58 GMT
Message-ID: <singletons-20231004125510@ram.dialup.fu-berlin.de>
References: <ZRhwWN29i3mskxEL@hermes.hilbert.loc> <ecc36615-1844-455f-b701-2bd41d98e9e1@DancesWithMice.info> <ZRigRwHpNReUo5rF@hermes.hilbert.loc> <4f1c9568-3850-4847-b357-740f79b0a79b@DancesWithMice.info> <ZRlelmUwOR/wcPqR@hermes.hilbert.loc> <f093d0a9-67b3-4baa-baae-3666c9847a14@DancesWithMice.info> <mailman.392.1696393517.23016.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de F3LStlc+JAHPoPP3Ho+j1AIclbq9aiRAMxUcZ5ypAOBjG4
Cancel-Lock: sha1:zMQaVfLahS4B9dVe4azeSXRFc7c= sha256:4L6LAkKZhUHPnWVtws8Wtj3N8Pz0rTFYUnKvWYPew0k=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
	Distribution through any means other than regular usenet
	channels is forbidden. It is forbidden to publish this
	article in the Web, to change URIs of this article into links,
        and to transfer the body without this notice, but quotations
        of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
	services to mirror the article in the web. But the article may
	be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR

dn <PythonList@DancesWithMice.info> writes:
>- should the class have been called either;
>     class SomethingSingleton():
>or a Singleton() class defined, which is then sub-classed, ie

  A singleton is a single instance of a class that usually is 
  used "globally" in an application. Such as "root" in

import logging

root = logging.getLogger()

  . So, when a singleton is needed in Python, I would follow
  the model of "getLogger". You do not have to put in effort
  to keep any client from creating more than one instance of
  a class. Multiple instances of a class intended for singletons
  might help when one is writing tests for this class.

  (My above opinion was stolen from Brandon Rhodes.)