I have created a package named mod and placed a python file inside it (a.k.a: module). The name of the python file is printme.py.
I import the module in the below couple of ways.
import mod.printme
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'mod']
After this is executed, the name space is appended with the value mod. I expected this to have the value printme (which is the actual module name)
from mod import printme
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'printme']
After this is executed, correctly the name space is appended with the value printme as expected.
Technically, both are expected to import the module printme in the local namespace, I am little puzzled why the first approach is NOT placing the printme module name in the local namespace.
Could someone please help me to understand.
Thanks!
mod.printme.function()- thereforemodneeds to be accessible to python. in the second versioun you would callprintme.function()- here only the nameprintmemust be defined.