What's the benefit of doing import package.submodule?

Viewed 108

Using numpy as an example, I can't seem to realize what the benefit of doing an import like this would accomplish:

import numpy.lib

after the import finishes, numpy is available as a name, equivalent to if you imported it directly:

import numpy

in both cases, you can access the submodule lib only with dotted access:

>>> numpy.lib
<module 'numpy.lib' from ....>

is there a case where doing import numpy.lib would be beneficial?

1 Answers
Related