On Fri, Sep 3, 2021 at 7:35 PM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Fri, Sep 03, 2021 at 03:43:03PM +1000, Chris Angelico wrote:
>
> > Yes, although I'd love to have a good term for "there is only ever one
> > object of this type AND VALUE", rather than "there is only one object
> > of this type", so that True and False could be discussed the same way
> > as singletons.
>
> I believe that the "official" Design Pattern name for something that
> generalisations the Singleton pattern to two or more instances is the
> Multiton:
>
> https://en.wikipedia.org/wiki/Multiton_pattern
>
> but most people just use the term "singleton" in the sense that there is
> only a single True and a single False. Or sometimes "dupleton" or
> "doubleton".
>
> Another term sometimes used is "flyweight", which is also used for
> interned strings and ints.
>
> https://python-patterns.guide/gang-of-four/flyweight/

Fair enough. I'll try to remember that one. Useful term, although a
little less than intuitive.

> What would you call a class that has *no* instances? Obviously that
> would only be useful in a language where classes are first-class
> citizens. Why create a singleton instance if you can just use the class
> object itself?
>

Based on the way Java seems to use it, probably "namespace" would be
the best term. Effectively, a class that never gets instantiated is a
storehouse for static methods, which means it's basically what Python
would do with a module full of top-level functions.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LCKZZRN2VR6PVZ4HC2Q5THNQR6WR6KZI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to