better approach is to write general tool to do transitive reloads automatically by scanning modules__dict__ namespace attributes and checking each item' type to find nested modules to reload such utility function could call itself recursively to navigate arbitrarily shaped and deep import dependency chains module __dict__ attributes were introduced in and employed earlier in this and the type call was presented in we just need to combine the two tools the module reloadall py listed next defines reload_all function that automatically reloads moduleevery module that the module importsand so onall the way to the bottom of each import chain it uses dictionary to keep track of already reloaded modulesrecursion to walk the import chainsand the standard library' types modulewhich simply predefines type results for built-in types the visited dictionary technique works to avoid cycles here when imports are recursive or redundantbecause module objects are immutable and so can be dictionary keysas we learned in and set would offer similar functionality if we use visited add(moduleto insert#!python ""reloadall pytransitively reload nested modules ( xcall reload_all with one or more imported module module objects ""import types from imp import reload from required in def status(module)print('reloading module __name__def tryreload(module)tryreload(moduleexceptprint('failed%smoduledef transitive_reload(modulevisited)if not module in visitedstatus(moduletryreload(modulevisited[moduletrue for attrobj in module __dict__ values()if type(attrobj=types moduletypetransitive_reload(attrobjvisiteddef reload_all(*args)visited {for arg in argsif type(arg=types moduletypetransitive_reload(argvisited advanced module topics (only?fails on some trap cyclesduplicates reload this module and visit children for all attrs recur if module main entry point for all passed in