我想做的是这样的:
template.py
def dummy_func():
print(VAR)
# more functions like this to follow
fabfile.py
# this gets called by fabric (fabfile.org)
# safe to think of it as ant build.xml
import template
template.VAR = 'some_val'
from template import *
即我有一个模板模块,其他模块应该“扩展”贡献所需的变量。这可以以功能方式完成(与对象继承相反)吗?
编辑:添加了更多代码。