Oh no! Somebody has hacked our secret string. Good thing we checked! This is Python name mangling at work. When we use a double underscore, the property is prefixed with
_<classname>. When methods in the class internally access the variable, they are automatically unmangled. When external classes wish to access it, they have to do the name mangling themselves. So, name mangling does not guarantee privacy, it only strongly recommends it. Most Python programmers will not touch a double underscore variable on another object unless they have an extremely compelling reason to do so.
However, most Python programmers will not touch a single underscore variable ...
- Who can access my data?
- from Python 3 Object-oriented Programming - Second Edition
- Publisher: Packt Publishing
- Released: August 2015
access controller work around for python
Share this highlighthttp://www.safaribooksonline.com/a/python-3-object-oriented/1901352/