dhirendranaga
9 years agoOccasional Contributor
How to verify that import in Python is successful
Have an import in a function that is called multiple times and this function is called only as required, sample is below. def importTest() import time statement1 statement2 def Test(...
- 9 years ago
Hi Dhirendranaga,
Please refer to the following Python article. I guess it answers your question:
As new modules are imported, they are added to sys.modules. This explains why importing the same module twice is very fast: Python has already loaded and cached the module in sys.modules, so importing the second time is simply a dictionary lookup.