What's better, ConfigObj or ConfigParser?

后端 未结 3 1766
面向向阳花
面向向阳花 2021-02-04 01:07

Which is better for creating a settings file for Python programs, the built-in module (ConfigParser), or the independent project (ConfigObj)?

3条回答
  •  深忆病人
    2021-02-04 01:30

    I recently switched from configparser to configobj, and I'm thrilled to have done so.

    For me, the big difference is configobj's validator. It lets me very easily/succinctly (1) define the type and acceptable values for each entry, and (2) set defaults.

    Those two features save me a lot of code and prevent a lot from going wrong. Plus, there's really no extra overhead to using configobj in terms of the complexity of my code, and the library is quite small.

提交回复
热议问题