【发布时间】:2015-04-21 15:27:36
【问题描述】:
假设我有两个脚本:functions.py 和 algorithm.py。在前者中我编写了在后者中导入的函数,后者是在终端中运行的脚本。
所以我在 algorithm.py 中的脚本如下所示:
import functions
x = functions.a_function()
例如,如果我在 a_function() 中使用 numpy,但我没有在 algorithm.py 的其他地方使用它,我应该在 functions.py 或 algorithm.py(或两者)中导入 numpy 吗?
由于我在 python 方面缺乏经验,我想知道人们通常如何解决这个特定问题。
非常感谢。
【问题讨论】: