Python gives us the ability to create \'private\' methods and variables within a class by prepending double underscores to the name, like this: __myPrivateMethod()
Why are Python's 'private' methods not actually private?
As I understand it, they can't be private. How could privacy be enforced?
The obvious answer is "private members can only be accessed through self
", but that wouldn't work - self
is not special in Python, it is nothing more than a commonly-used name for the first parameter of a function.