workand is generally preferred in more recent pythons for direct calls to import by name string--at least per the current "officialpolicy stated in python' manualsimport importlib modname 'stringstring importlib import_module(modnamestring the import_module call takes module name stringand an optional second argument that gives the package used as the anchor point for resolving relative importswhich defaults to none this call works the same as __import__ in its basic rolesbut see python' manuals for more details though both calls still workin pythons where both are availablethe original __import__ is generally intended for customizing import operations by reassignment in the built-in scope (and any future changes in "officialpolicy are beyond the scope of this book!exampletransitive module reloads this section develops module tool that ties together and applies some earlier topicsand serves as larger case study to close out this and part we studied module reloads in as way to pick up changes in code without stopping and restarting program when you reload modulethoughpython reloads only that particular module' fileit doesn' automatically reload modules that the file being reloaded happens to import for exampleif you reload some module aand imports modules and cthe reload applies only to anot to and the statements inside that import and are rerun during the reloadbut they just fetch the already loaded and module objects (assuming they've been imported beforein actual yet abstract codehere' the file pya py import import not reloaded when isjust an import of an already loaded moduleno-ops python from imp import reload reload(aby defaultthis means that you cannot depend on reloads to pick up changes in all the modules in your program transitively--insteadyou must use multiple reload calls to update the subcomponents independently this can require substantial work for large systems you're testing interactively you can design your systems to reload their subcomponents automatically by adding reload calls in parent modules like abut this complicates the modulescode exampletransitive module reloads