我要导入在文件中定义的函数,如
this question
进入测试(不要问为什么…遗留系统和插件系统的结合)
import imp
module = imp.load_source('module', '/path/to/file.py')
module.some_function()
但得到
NameError: name '<SOME-VARIABLE>' is not defined
.
'<SOME-VARIABLE>'
未在中定义
/path/to/file.py
但在
/another/path/to/another/file.py
. 有可能给猴子打补丁吗
<SOME-VARIABLE>
是否允许导入文件/模块?