title: How to Break Import Loop in python
body: <p>I have a situation where there two related large  python classes and hence i have put them in separate files. Let say classes are Cobra and Rat.</p>
  
  <p>Now need to call methods of Rat from methods of Cobra and vice versa.
  For this i need to import Cobra in Rat.py and Rat in Cobra.py</p>
  
  <p>This creates an import loop and gives an error. Cant import Cobra inside Cobra.</p>
  
  <p>How to fix this??</p>
  
  <p><strong>Cobra.py</strong>:</p>
  
  <pre><code>import Rat
  class Cobra():
      def check_prey(self, rat ):
          # Some logic 
          rat.foo()
  </code></pre>
  
  <p><strong>Rat.py</strong>:</p>
  
  <pre><code>import Cobra
  class Rat():
      def check_predator(self, snake ):
          # some_logic ..
          snake.foo()
  </code></pre>