Python: Is it meaningful to import sub-package?
Question: This statement is from [Python 3
Doc](https://docs.python.org/3/tutorial/modules.html):

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

It says we can `from package import subpackage`.

Here I create a package `audio`, and two subpackage `format` and `sound`.

[![enter image description
here](http://i.stack.imgur.com/JCNLm.png)](http://i.stack.imgur.com/JCNLm.png)

Then I import its subpackage :

    
    
    from audio import sound
    
    print(type(sound))
    

The output is

> class 'module'

It shows that for `from package import subpackage`, Python intepreter always
takes the item as `module`, not `subpackage`.

    
    
    from audio import sound
    
    print(type(sound.echo))
    

Moreover, since `sound` is taken as `module`, how to access its `echo` module?

it will raise

> AttributeError: module 'audio.sound' has no attribute 'echo'

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


Answer: There is only a
[`module`](https://docs.python.org/3/library/stdtypes.html#modules) type in
Python, `subpackage` is not a type.

All packages and subpackages are modules.

> is it possible to import subpackage

Yes? You already imported `sound` as a subpackage of `audio`...

> is it meaningful to import sub-package

Also, yes. How else would you use the classes and functions defined by any
module?

If you would like to import `echo`, then do so like this

    
    
    from audio.sound import echo 
    

