Observer Observable classes in python
<p>How do I write a program with observer/ observable facilities in Python as in Java?
I'd write something like following in Java.</p>

<pre><code>import java.util.Observable;
import java.util.Observer;


public class ObservDemo extends Object {
  MyView view;
  MyModel model;

  public ObservDemo() {

    view = new MyView();
    model = new MyModel();
    model.addObserver(view);

  }

  public static void main(String[] av) {
    ObservDemo me = new ObservDemo();
    me.demo();
  }

  public void demo() {
    model.changeSomething();
  }

  /** The Observer normally maintains a view on the data */
  class MyView implements Observer {
    /** For now, we just print the fact that we got notified. */
    public void update(Observable obs, Object x) {
      System.out.println("update(" + obs + "," + x + ");");
    }
  }

  /** The Observable normally maintains the data */
  class MyModel extends Observable {
    public void changeSomething() {
      // Notify observers of change
      setChanged();
      notifyObservers();
    }
  }
}
</code></pre>

<p>(This code is take from the following link
<a href="http://www.java2s.com/Code/Java/Design-Pattern/AsimpledemoofObservableandObserver.htm" rel="nofollow">http://www.java2s.com/Code/Java/Design-Pattern/AsimpledemoofObservableandObserver.htm</a> )</p>

<p>how do I accomplish in such thing in Python?</p>
