title: cyclic import AttributeError: 'module' object has no attribute
body: <p>I am trying to understanding cyclic import problem, Here I have three python files,</p>
  
  <p><strong>py1.py</strong></p>
  
  <pre><code>import py3
  py3.test3()
  def test1():
      print 'test 1'
  </code></pre>
  
  <p><strong>py2.py</strong></p>
  
  <pre><code>import py1
  py1.test1()
  def test2():
      print 'test 2'
  </code></pre>
  
  <p><strong>py3.py</strong></p>
  
  <pre><code>import py2
  py2.test2()
  def test3():
      print 'test 2'
  </code></pre>
  
  <p>when I run the <code>python py3.py</code> and got the error like this,</p>
  
  <pre><code>Traceback (most recent call last):
    File "py3.py", line 1, in &lt;module&gt;
      import py2
    File "/home/me/Desktop/hackerearth/cylic/py2.py", line 1, in &lt;module&gt;
      import py1
    File "/home/me/Desktop/hackerearth/cylic/py1.py", line 1, in &lt;module&gt;
      import py3
    File "/home/me/Desktop/hackerearth/cylic/py3.py", line 3, in &lt;module&gt;
      py2.test2()
  AttributeError: 'module' object has no attribute 'test2'
  </code></pre>
  
  <p>But when I remove the <code>import py3</code> from py1.py file I got the output without any errors. Any one explain me why I am got this error. </p>