Re: Change "__propertyName" or "__functionName" as invisible parts in a class forcely

Chris Angelico via Python-list <[email protected]> Wed, 27 May 2026 05:58:39 +1000
Newsgroups gmane.comp.python.general
Message-ID <CAPTjJmrR-EQhX3wvnXT5gzMWTSjo1XGiwy1dUc=KoNRQzaWXTw@mail.gmail.com>
On Wed, 27 May 2026 at 05:57, Gregg Drennan <[email protected]> wrote:
> Starting a class method or properly with a double-underscore causes "name mangling" which kind of hides the name, but not really.
>

More specifically, the name mangling is not intended to hide anything,
but to allow classes in a hierarchy to avoid trampling over each
other's names. If you want to subclass something, add an attribute to
it, and be 100% confident that you aren't accidentally stepping on an
existing attribute, double underscore prefix it.

ChrisA