Home >Backend Development >Python Tutorial >python code to create configure file
In Lua, Lua is always used as a config file or a file carrying data - the advantage is that Lua itself is easy to read, and there is no need to write additional parsing code. It also supports reading environment variables, conditional judgments, etc. in the configure file.
Achieved in lua through 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']
The disadvantage is that unlike lua, you can access variables in the table as members, such as ns.foo, ns.bar...