Python Forum
Packages and Modules - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Packages and Modules (/thread-8635.html)



Packages and Modules - grkiran2011 - Mar-01-2018

Hi Viewer,

import my_lib
import my_lib.my_sound
When I checked locals() listing, I do not see any difference. How does python know that I have imported a sub-package under my_lib.

Thanks,
Kiran.


RE: Packages and Modules - Gribouillis - Mar-01-2018

(Mar-01-2018, 12:30 PM)grkiran2011 Wrote: How does python know that I have imported a sub-package under my_lib.
A new module instance is stored at address sys.modules['my_lib.my_sound']. The subpackage's code has been run in the module's __dict__ dictionary.