A Single Instance of an Object?

Chris Angelico rosuav at gmail.com
Mon Mar 11 16:57:51 EDT 2024


On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list
<python-list at python.org> wrote:
> I am refactoring some code and I would like to get rid of a global
> variable. Here is the outline:
>
> ...
>
> I have never done that in Python because I deliberately avoided such
> complicated situations up to now. I know about the Singleton pattern,
> but I have never implemented it in Python and I don't know if it is
> Pythonish.
>

A Singleton is just a global variable. Why do this? Did someone tell
you "global variables are bad, don't use them"?

ChrisA


More information about the Python-list mailing list