Chris' response is dead on.  Python was never designed or intended to have
private variables, methods or classes, like many other languages do.

Starting a name with an underscore is a well documented
construct/understanding/standard meaning not to use this directly but
instead use the "public" method vs being an enforced rule.

Starting a class method or properly with a double-underscore causes "name
mangling" which kind of hides the name, but not really.

Bottom line to to learn and teach new Python developers the standards and
Pythonic way.

On Tue, May 26, 2026, 2:30 PM Chris Angelico via Python-list <
[email protected]> wrote:

> On Wed, 27 May 2026 at 04:16, <[email protected]> wrote:
> >
> > As u all know, when we're starting to define a private member or a
> function in Python, led by "__", some like this following:
> >
> > class MyClass:
> >
> >     __privateMember = your initValue Here
> >
> >     def __myPrivateMethod(self):
> >         # do what u want here...
> >
> > Now you can still access the private member or private method through
> the "_MyClass__myPrivateMethod()" or "_myClass__privateMember".
> >
> > What I wanna say here is:
> >
> > 1. This WON'T give those who begin to learn Python a good understanding
> of "private method/private member" for OOP,.
> > 2. Since it's private, why could we still access them? It will sometimes
> gives a programmer a bad / lazy way of assignment to the private things.
> >
>
> They are not private. You're under a very much mistaken impression.
> They've never been private and there's no intention ever to make them
> private.
>
> ChrisA
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to