class A():
def __init__(self):
self.public='public'
self._protected='protected'
self.__private='private'
v=A()
print(v.public)
print(v._protected)
print(v.__private)
public
protected
Traceback (most recent call last):
File "WHATEVER FILENAME IT IS
", line 10, in <module>
print(v.__private)
AttributeError: 'A' object has no attribute '__private'
So default is public, _something
is protected and __something
is private.
However:
class A():
def __init__(self):
self.public='public'
self._protected='protected'
self.__private='private'
def p(self):
print(self.__private)
v=A()
v.p()
private