0

in python when I need to use a function I have to import the entire module or the specific function in the module.
What if I import directly a module and the same module is imported from another module that I import later?
Just for example in a hypothetical `myapp.py` there are theese three rows:
import module1
import module2
import module3

in module1.py there are other importing instructions like

import mymodule
import module2
import module4

The chain of import modules can ben longer than that in a regular application.
If I well understood when I run myapp.py the interpreter runs the first line import module1 and then opens module1.py and start processing it, starting from its first line import mymodule then the second import module2 and so on. But when returning to second line of myapp.py it has to process

import module2

that has been already processed! What does happens in that situation?
I have to be aware of all the duplicating coding calls or simply python itself discard the second import module2 call because he knows it has already done the import?
In big (and usual) apps, it's common to use very large amount of libraries (modules): how can I check all the cross calls between modules and secondly should I worry about it?
Regards, Marco

boerig
  • 21
  • 2

1 Answers1

0

sorry for the noise....I've found that this question was already answered in `https://stackoverflow.com/questions/19077381/what-happens-when-a-module-is-imported-twice`
boerig
  • 21
  • 2