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: References: <4f1c9568-3850-4847-b357-740f79b0a79b@DancesWithMice.info> 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 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.)