Python: Is it meaningful to import sub-package?
<p>This statement is from <a href="https://docs.python.org/3/tutorial/modules.html" rel="nofollow noreferrer">Python 3 Doc</a>:</p>

<blockquote>
  <p>Note that when using from package import item, the item can be either a submodule (or subpackage) of the package ...</p>
</blockquote>

<p>It says we can <code>from package import subpackage</code>.</p>

<p>Here I create a package <code>audio</code>, and two subpackage <code>format</code> and <code>sound</code>.</p>

<p><a href="https://i.stack.imgur.com/JCNLm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JCNLm.png" alt="enter image description here"></a></p>

<p>Then I import its subpackage :</p>

<pre><code>from audio import sound

print(type(sound))
</code></pre>

<p>The output is </p>

<blockquote>
  <p>class 'module'</p>
</blockquote>

<p>It shows that for <code>from package import subpackage</code>, Python intepreter always takes the item as <code>module</code>, not <code>subpackage</code>.</p>

<pre><code>from audio import sound

print(type(sound.echo))
</code></pre>

<p>Moreover, since <code>sound</code> is taken as <code>module</code>, how to access its <code>echo</code> module?</p>

<p>it will raise </p>

<blockquote>
  <p>AttributeError: module 'audio.sound' has no attribute 'echo'</p>
</blockquote>

<p>Hence, I wonder whether it is meaningful to import sub-package, or is it possible to import subpackage?</p>