【发布时间】:2012-05-20 16:54:02
【问题描述】:
如果我给一个模块打补丁:
# mokeypatch.py
import other_module
def replacement(*args, **kwargs):
pass
other_module.some_func = replacement
这会影响直接导入some_func 的模块,还是取决于导入的顺序?如果第三个模块是这样的:
# third_module.py
from other_module import some_func
首先,运行这段代码,然后运行我们的猴子补丁。 third_module.some_func 会是旧的吗?
【问题讨论】:
标签: python import namespaces monkeypatching