Private Variables and Methods in Python [duplicate]
Please note that there is no such thing as “private method” in Python. Double underscore is just name mangling: >>> class A(object): … def __foo(self): … pass … >>> a = A() >>> A.__dict__.keys() [‘__dict__’, ‘_A__foo’, ‘__module__’, ‘__weakref__’, ‘__doc__’] >>> a._A__foo() So therefore __ prefix is useful when you need the mangling to occur, for … Read more