When you import a module, then reimport it again, will it get reimported/overwritten, or skipped?
When you import module “a” and “b”, but also have module “b” imported in module “a”, what happens? Is it safe to do this? For example if that module “b” has a class instantiated in it, will you end up instantiating it twice?
When you import a module, then reimport it again, will it get reimported/overwritten, or
Share
importloads the matching.py,.pycor.pyofile, creates a module object, and stores it with its fully qualified (“dotted”) name in thesys.modulesdictionary. If a secondimportfinds the module to import in this dictionary, it will return it without loading the file again.To answer your questions:
It will get skipped. To explicitely re-import a module, use the
reload()built-in function.import awill loadafroma.py[c],import bwill return the modulesys.modules['b']already loaded bya.Yes, absolutely.
Nope.