title: Python import module with alias
body: <p>I am newbie to Python 3 and currently learning how to create Python modules. I have created below package structure.</p>
  
  <pre><code>maindir
      test.py
      package
          __init__.py
          subpackage
              __init__.py
              module.py
  </code></pre>
  
  <p>This is my module.py file</p>
  
  <pre><code>name="John"
  age=21
  </code></pre>
  
  <p>and this is my test.py file</p>
  
  <pre><code>import package.subpackage.module
  print(module.name)
  </code></pre>
  
  <p>When I run test.py I am getting this error <code>NameError: name 'module' is not defined</code>
  However, when I change the import statement to <code>import package.subpackage.module as mymod</code> and print the name with <code>print(mymod.name)</code> then its working as expected. Its printing name John.
  I didn't understand why its working with second case and not with first.</p>