Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

I think below doc gives some indication that it always occurs within the 
definition of the class (hence inside a static method) irrespective of the 
syntactic position for any valid identifier and hence for class 
__SuperPrivateClass too. I will let others explain on this better or give more 
information.

https://docs.python.org/3/tutorial/classes.html#private-variables (second 
paragraph)

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.

SO answer that gave me the link : https://stackoverflow.com/a/1301369/2610955

Thanks

----------
nosy: +xtreak

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34196>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to