Python: How to import a class in the same module/file
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6402522/python-mutually-dependent-classes-circular-dependencies">Python mutually dependent classes (circular dependencies)</a>  </p>
</blockquote>



<p>I have 2 class in the same module/file, and they use one another.</p>

<pre><code>class ClassA:
    x = ClassB()

class ClassB:
    x = ClassA()
</code></pre>

<p>ClassA would have a problem since the declaration of ClassB is after ClassA, hence ClassB is not found. </p>

<p>How do I solve this? Can I somehow import ClassB?</p>

<hr>

<p>Update: My bad. The example above has a circular reference, and that disgusted many people.. Let me try again:</p>

<pre><code>class ClassA:
    x = 1
    y = ClassB.x

class ClassB:
    x = 2
    y = ClassA.x
</code></pre>

<p>Can I somehow import ClassB before ClassA implementation? Or some sort of forward class declaration.</p>
