change an object variable from other object(delegation)
<p>I am using python to implement something like following. </p>

<p>sample1.py</p>

<pre><code>Class D:
    def __ini__(self):
        return  

    def disconnect(self):
        ## I want to change isConnected in A, but I can not do something like A.isConnected = False here. I want to use delegation.
        return 
</code></pre>

<p>sample2.py</p>

<pre><code>Class B(A):
    Class C(D):
         def _init_(self):
             super(B.C,self)._init_()

         def foo():
             if self.isConnected:
                print "error"

    def __init__(self):

        super(C, self).__init__()
</code></pre>

<p>sample3.py</p>

<pre><code>Class A(Object):
    def __init__(self):
        self.isConnected = False
</code></pre>

<p>Whenever D.disconnect() is executed, I want to change A.isConnected value. If i am not allowed to call A.isConnected = False. How can I use delegation to achieve my goal. </p>

<p>It would be great if you can provide some hints or suggestions.</p>

<p>Thanks  </p>

<p>I'm unclear on your objective. Sounds like you want to edit a variable before it is created. </p>

<p>If that is not the case, you should be able to change A.isConnected with the following code: </p>

<p><code>A.isConnected = True</code></p>

python oop design-patterns