information-hiding

Why are Python's 'private' methods not actually private?

Why are Python's 'private' methods not actually private? Question: Python gives us the ability to create ‘private’ methods and variables within a class by prepending double underscores to the name, like this: __myPrivateMethod(). How, then, can one explain this >>>> class MyClass: … def myPublicMethod(self): … print ‘public method’ … def __myPrivateMethod(self): … print ‘this …

Total answers: 12