基于python的配置读取器
pyconf的Python项目详细描述
基于python的配置读取器
很简单,将文件加载到python模块对象中,但不将其放置 在模块缓存中或以其他方式绑定它。
>>> import posixpath >>> conf = load(posixpath.__file__) >>> conf # doctest: +ELLIPSIS <module '<config>' from '...'> >>> conf.pathsep ':'
等等。您也可以使用加载dict来获取dict:
>>> type(load_dict(posixpath.__file__)) <type 'dict'>
但是,如果尝试加载无法识别或加载的文件,则 错误:
>>> load("lala.ini") Traceback (most recent call last): ... ConfigurationError: no suitable loader for config module 'lala.ini'