Python OOO coding with parent child relationship
<p>I have a parent and child class. Parent class has 2 attributes x,y. Y can be set to private variable with __(double underscore) but I can't expose it to the child class, so I have given it as a _(single underscore) exposing it to the child class.</p>

<p>But I don't want it to be exposed other than the child class..</p>

<p>Is there anyway to override the init class in the child method to protect the y variable being exposed?</p>

<p>test.py</p>

<pre><code>class parent:

    def __init__(self,x):
        self.x = x
        self._y =   ' '
        self.setyvalue()

    def setyvalue(self):
        self._y = 10
        return self._y 
class child(parent):
    def test(self):
        print('self.x',self.x)
        print('self._y',self._y)

if __name__ == '__main__':
    x = child(2)
    x.test()
</code></pre>
