This function is invoked by the import statement. It can be replaced
(by importing the builtins module and assigning to
builtins.__import__) in order to change semantics of the import
statement
import builtins
original_import = builtins.__import__
def custom_import(*args, **kw):
module = original_import(*args, **kw)
if (module.__name__ == "interesting_module"
and not getattr(module, "patch_is_performed", False)):
patch(module)
module.patch_is_performed = True
return module
builtins.__import__ = custom_import
我选择了包装^{} :
相关问题 更多 >
编程相关推荐