title: Python How Can I make base class file can import from child class file
body: <p>I meet a python import loop problem. And I don't want merge the two pieces code into one file. What can i do?</p>
  
  <pre><code>$ tree
  .
  ├── testBase.py
  └── testChild.py
  </code></pre>
  
  <p>testBase.py：</p>
  
  <pre><code>from testChild import Child
  
  class Base(object):
  
      def __init__(self, obj):
  
          ## For some rease need detect obj
          if isinstance(obj,  Child):
              print("test")
  </code></pre>
  
  <p>testChild.py:</p>
  
  <pre><code>from testBase import Base
  
  class Child(Base):
  
      def __init__(self):
          pass
  </code></pre>
  
  <p>With Error:</p>
  
  <pre><code>$ python testChild.py
  Traceback (most recent call last):
    File "testChild.py", line 1, in &lt;module&gt;
      from testBase import Base
    File "/cygdrive/d/Home/test_import/testBase.py", line 2, in &lt;module&gt;
      from testChild import Child
    File "/cygdrive/d/Home/test_import/testChild.py", line 1, in &lt;module&gt;
      from testBase import Base
  ImportError: cannot import name Base
  </code></pre>
  
  <p>I can make import in run time like this:</p>
  
  <pre><code>class Base(object):
  
      def __init__(self, obj):
          from testChild import Child
          ## For some rease need detect obj
          if isinstance(obj,  Child):
              print("test")
  </code></pre>
  
  <p>I want to know Is this the only way to fix this problem? Is there a good method?   </p>