Given that foo.bar
is a module, what is the difference between
import foo.bar as bar
and
from foo import bar
I'm particularly interested in what lazy importing of modules does to this.
Note: This is not a duplicate of this question.
Given that foo.bar
is a module, what is the difference between
import foo.bar as bar
and
from foo import bar
I'm particularly interested in what lazy importing of modules does to this.
Note: This is not a duplicate of this question.
In the first code line:
import foo.bar as bar
Here you are importing bar
from foo
package but why added as bar
means when you need to access any function func
in that bar
. You have to access like
foo.bar.func
but when you added as bar
you just use
bar.func
The same to the line from foo import bar
just importing the bar