how to trigger function in another object when variable changed. Python
<p>As far as I know, this is like an Observer pattern. 
Scenario: <strong>A Center object keeps a list (queue) of all its clients.</strong> I'm using Twisted.</p>

<ol>
<li>One of client objects <strong>changes a variable</strong> in center object OR notify the center to change the variable, </li>
<li>and then the center object <strong>detects the change</strong> immediately; </li>
<li>then as soon as the detection, the center object invoke some function <strong>of next object</strong> in queue</li>
<li>After the client changed the variable, <strong>the client object will be <em>eliminated.</em></strong> The center will take care of next client object. So I imagine there's no any function chain between these objects. So it's a little bit different from observer pattern.  (How to address this issue? Correct me if I'm wrong.)</li>
</ol>

<p>following code is just for demo only:</p>

<pre><code>    class client():
        def change(self):
            self.center.va = 1

        def inqueue(self):
            self.center.queue.enqueue(self)

        def function(self):
            pass

    class center():
        def __init__(self):
            self.queue = None
            self.va = 0

        ####  When the self.va changes, this func will be invoked
        def whenChanged(self):
            next = self.queue.dequeue()
            next.function()
</code></pre>

<p>Make <code>va</code> a property.</p>

<pre><code>class Center():
    def __init__(self):
        self.queue = None
        self._va = 0

    @property
    def va(self):
        return self._va

    @va.setter
    def va(self, value):
        self._va = value
        self.whenChanged()

    def whenChanged(self):
        next = self.queue.dequeue()
        next.function()
</code></pre>

python