Re: A Single Instance of an Object?

Liste des GroupesRevenir à cl python 
Sujet : Re: A Single Instance of an Object?
De : rambiusparkisanius (at) *nospam* gmail.com (Ivan \"Rambius\" Ivanov)
Groupes : comp.lang.python
Date : 11. Mar 2024, 23:04:32
Autres entêtes
Message-ID : <mailman.88.1710191087.3452.python-list@python.org>
References : 1 2 3
On Mon, Mar 11, 2024 at 5:01 PM Chris Angelico via Python-list
<python-list@python.org> wrote:
>
On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list
<python-list@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"?

I have bad experience with global variables because it is hard to
track what and when modifies them. I don't consider them bad, but if I
can I avoid them.

Regards
rambius

--
Tangra Mega Rock: http://www.radiotangra.com

Date Sujet#  Auteur
11 Mar 24 o Re: A Single Instance of an Object?1Ivan \"Rambius\" Ivanov

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal