我有三个python脚本job.py,control1和control2该job.py文件是另一个项目的一部分,并假设我无权对其进行修改。job.py... execfile(self.control, global_control_vars, global_control_vars)...self.control 拥有通往的绝对路径 control1控制1import imp,osa='path/to/control2'imp.load_source('control2',a)控制2...for i in tests: job.run_test('pax', test = i, tag = i, archive = ARCHIVE)...现在的job问题。control2中的in在job.py的命名空间中。job.py执行代码时,出现以下错误。File "job.py", line 1170, in step_engine execfile(self.control, global_control_vars, global_control_vars)File "tests/linux-tools/control1", line 18, in <module> imp.load_source('control',a)File "tests/linux-tools/pax/control2", line 22, in <module> job.run_test('pax', test = i, tag = i, archive = ARCHIVE)NameError: name 'job' is not defined(路径名已缩短)有什么方法可以将job引入执行control1位置的名称空间control2吗?或者有没有办法像在C / C ++这样的语言中进行预处理一样导入代码[ control2] control1?也就是说,来自该位置的代码被“粘贴”到该语句的位置。
添加回答
举报
0/150
提交
取消