This is a good way to implement module overloading after reading the Python Learning Manual, which can be implemented to reload a module that has already been loaded in a running program, and the module can be recursively implemented to reload other modules referenced within the module to be reloaded.
"" "Reloadall.py:transitively Reload nested Modules" "" Import typesfrom Imp import reloaddef status (module): print (' Reloading ' +module.__name__) def transitive_reload (module, visited): if not module in visited: status (module) Reload (module) visited[module]=none for attrobj in Module.__dict__.values (): if Type (attrobj) = = Types. Moduletype: transitive_reload (Attrobj, visited) def Reload_all (*args): visited={} for arg in args: Transitive_reload (ARG, visited) if __name__== "__main__": import Reloadall reload_all (Reloadall)
Attention:
The code for this module is fully referenced in the Python Learning manual book.
Python module overloads for bridging modules