Why are Python’s ‘private’ methods not actually private?

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 is private!!’ … >>> obj = MyClass() >>> obj.myPublicMethod() … Read more