title: Nested Package: AttributeError: module 'app' has no attribute
body: <p>I'm just learning python, coming from a C# &amp; Java background, and I'm pretty confused by the import system.  Just trying to run a simple test for learning purposes, but getting an error AttributeError: module 'app' has no attribute 'example'</p>
  
  <p>See code below, can someone explain why the error is thrown?  I only seem to encounter this issue when there's a package inside a package, as seen in the instance of package "example" contained inside package "app"</p>
  
  <p><strong>run.py</strong></p>
  
  <pre><code>import app
  </code></pre>
  
  <p><strong>app/__init__.py</strong></p>
  
  <pre><code>import app.example
  </code></pre>
  
  <p><strong>app/example/__init__.py</strong></p>
  
  <pre><code>import app.example.a
  </code></pre>
  
  <p><strong>app/example/a.py</strong></p>
  
  <pre><code>import app.example.b
  print("TESTING: " + str(app.example.b)) #error is thrown on this line
  </code></pre>
  
  <p><strong>app/example/b.py</strong></p>
  
  <pre><code>print("LOADED B")
  </code></pre>
  
  <p><strong>Error Thrown:</strong></p>
  
  <pre><code>"C:\Program Files\Python 3.5\npwc-services\Scripts\python.exe" C:/Users/xxxxxxxx/PycharmProjects/untitled1/run.py
  Traceback (most recent call last):
  LOADED B
    File "C:/Users/xxxxxxxx/PycharmProjects/untitled1/run.py", line 1, in &lt;module&gt;
      import app
    File "C:\Users\xxxxxxxx\PycharmProjects\untitled1\app\__init__.py", line 1, in &lt;module&gt;
      import app.example
    File "C:\Users\xxxxxxxx\PycharmProjects\untitled1\app\example\__init__.py", line 1, in &lt;module&gt;
      import app.example.a
    File "C:\Users\xxxxxxxx\PycharmProjects\untitled1\app\example\a.py", line 2, in &lt;module&gt;
      print("TESTING: " + str(app.example.b))
  AttributeError: module 'app' has no attribute 'example'
  
  Process finished with exit code 1
  </code></pre>
  
  <p><strong>Directory Structure:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/kK4gP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kK4gP.png" alt="enter image description here"></a></p>