python import module from a package
<p><strong>folder structure:</strong></p>

<pre><code>&lt;current dir&gt;
   main.py
   packages &lt;dir&gt;
      __init__.py
      mod.py
</code></pre>

<p><strong>main py:</strong> </p>

<pre><code>import packages
print packages.mod.hello()
</code></pre>

<p><strong>mod.py:</strong></p>

<pre><code>def hello():
    return 'hello'
</code></pre>

<p><strong>__init__.py:</strong></p>

<pre><code>from packages import mod
</code></pre>

<p>If I run <code>main.py</code>, I get no error. But if I edit <code>__init__.py</code> to <code>'from packages import *'</code> , I get this error: <strong>AttributeError: 'module' object has no attribute 'mod'</strong></p>

<p>I'm not asking how to make that <code>'print'</code> command work. I can use other <code>'import'</code> syntax in <code>main.py</code> to make it work. The question is: I'm curious about that <code>'from packages import mod'</code> in the <code>__init__.py</code>. If i can do <code>import mod</code> then when I replace to <code>import *</code>, which means import everything, why do I get an error instead?</p>

<p>So what does the <code>from packages import *</code> really mean inside that <code>__init__.py</code>?</p>

<p>Anyone can help? Thanks</p>