There is an interesting question on python 3.5. For example I've smth like:
class A:
__x = 0
def __init__(self, x):
self.__x = x
def set_x(self,x): __x=x
def get_x(self): return x
class B(A):
__y = 0
def __init(self, x, y)
self.__y = y
super(B, self).__init__(x)
def set_y(self,y): __y=y
def get_y(self): return y
def toString(self): return "x = {} and y = {}".format(self.__x,
self.__y);
test = B(7,3)
test.toString()
Why do I have an error here: "B object has no attribute _B__x", if the method super()
let me to use all methods of parante class?
Sure, if I write, like:
def toString(self): return "x = {} and y = {}".format(self.get_x(),
self.__y);
It works well!