不要写配置,写类声明。
bonfig的Python项目详细描述
邦菲格
from Bonfig import *
import configparser
class INIConfig(Bonfig):
store = Store()
SECTION = store.Section()
A = SECTION.FloatField()
def load(self):
self.store = configparser.ConfigParser()
self.store.read_string("[SECTION]\nA = 3.14159")
停止将配置编写为字典和奇怪的浮动数据类,使它们成为Bonfigs
,并利用
一大堆很棒的功能:
- 将配置声明为易于阅读的类。
- 获取配置中内置类的所有功能—多态性、自定义方法和自定义初始化。
- 睡眠安全,因为你的配置不会意外改变。
- 现成的序列化和反序列化,使用现成的自定义
Fields
-IntField
、FloatField
、BoolField
和DatetimeField
。
安装
pip install bonfig
有关详细信息,请在github上签出项目:https://0hughman0.github.io/bonfig/index.html