To make methods and properties private, all you need to do in Python is start with two underscores .
class Demo:
def __inaccessible(self):
print("HAHA, YOU CANNOT SEE ME")
def accessible(self):
print(The secret message is:)
self.__inaccessible()
But if you understand the processing mechanism behind, you can still access this private method in the following ways:
s = Demo()
s._Demo_inaccessible()
Therefore, it is generally agreed to use another way to start with an underscore .