hebedich 通过本文主要向大家介绍了python configure,configure文件,没有configure文件,linux configure文件,configure等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
(在lua中通过loadfile, setfenv实现)
python当然也可以:
cat config.py
bar = 10
foo=100
cat python_as_config.py:
ns = {}
execfile('config.py', ns)
print "\n".join(sorted(dir(ns)))
print "*"*80
print ns['foo']
print ns['bar']
</div>
缺点是不像lua那么可以以成员的方式访问table中的变量,如ns.foo, ns.bar...
例子: https://github.com/baiyanhuang/blog/tree/master/arena/python/python_as_config
</div>
