title: Connections between different classes
body: <p>please consider the following code:</p>
  
  <pre><code>class A:
      a = "a"
  
      def print_a(self):
          print("A says:", self.a)
  
      def print_warning_a(self):
          print("A says:", "Warning! B wrote something!")
  
  
  class B:
      b = "b"
  
      def print_a(self):
          print("B says:", self.b)
  
      def print_warning_b(self):
          print("B says:", "Warning! A wrote something!") 
  
  if __name__=="__main__":    
      class_a = A()
      class_b = B()
  
      class_a.print_a()
      class_b.print_b()
  </code></pre>
  
  <p>I would like the output to be something like:</p>
  
  <pre><code>&gt;&gt; A says: a
  &gt;&gt; B says: Warning! A wrote something!
  &gt;&gt; B says: b
  &gt;&gt; A says: Warning! B wrote something!
  </code></pre>
  
  <p>In other words: I have theese two classes (A and B). I would like to call a method of class A whenever another method of class B is called. Also, I would like to call a method of class B whenever another method of class A is called, assuming this would not cause an infinite loop (as in the example above).</p>
  
  <p>In this case I would like to call 
      print_warning_a()
  when
      print_b()
  of class B fires, and also I would like to call 
      print_warning_b()
  when
      print_a()
  of class A fires.</p>
  
  <p>How can I modify the code to achieve this?</p>
  
  <p>Thank you.</p>