ZhangZhihui's Blog  

Name mangling is the process of naming the variable using the prefix "__" (double underscore), which makes the variable can be accessed only by using the class name prefixed with "_" (single underscore) followed by the variable name with double underscore.

Situations might demand to access the private variables from the outside of the class. Here, Python's mangling process comes into the picture. The syntax for accessing a private variable from outside is,

 

posted on 2024-06-17 21:34  ZhangZhihuiAAA  阅读(12)  评论(0编辑  收藏  举报