This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author niharranjanroy
Recipients Dennis Sweeney, niharranjanroy
Date 2021-05-27.06:33:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAA9Cs4Ep1cspO1Sc8CSWuwMPt5BiUNSf_DiUm17J7+jZgCBmwg@mail.gmail.com>
In-reply-to <1622092639.16.0.908994957051.issue44244@roundup.psfhosted.org>
Content
Thank you dennis. This is helpful.

With Regards
Nihar Ranjan Roy
Mobile: +91 9810 977 908
___________________

On Thu, May 27, 2021 at 10:47 AM Dennis Sweeney <report@bugs.python.org>
wrote:

>
> Dennis Sweeney <sweeney.dennis650@gmail.com> added the comment:
>
> An attribute name starting with a single underscore is just a warning to
> users of your code that "this attribute is supposed to be private, access
> it at your own risk."
>
> Everything below is from
> https://docs.python.org/3/tutorial/classes.html?highlight=mangle#private-variables
> :
>
> “Private” instance variables that cannot be accessed except from inside an
> object don’t exist in Python. However, there is a convention that is
> followed by most Python code: a name prefixed with an underscore (e.g.
> _spam) should be treated as a non-public part of the API (whether it is a
> function, a method or a data member). It should be considered an
> implementation detail and subject to change without notice.
>
> Since there is a valid use-case for class-private members (namely to avoid
> name clashes of names with names defined by subclasses), there is limited
> support for such a mechanism, called name mangling. Any identifier of the
> form __spam (at least two leading underscores, at most one trailing
> underscore) is textually replaced with _classname__spam, where classname is
> the current class name with leading underscore(s) stripped. This mangling
> is done without regard to the syntactic position of the identifier, as long
> as it occurs within the definition of a class.
>
> Name mangling is helpful for letting subclasses override methods without
> breaking intraclass method calls. For example:
>
> ...
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue44244>
> _______________________________________
>
History
Date User Action Args
2021-05-27 06:33:17niharranjanroysetrecipients: + niharranjanroy, Dennis Sweeney
2021-05-27 06:33:17niharranjanroylinkissue44244 messages
2021-05-27 06:33:17niharranjanroycreate