What's better, ConfigObj or ConfigParser?

后端 未结 3 1765
面向向阳花
面向向阳花 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:43

    Depending on your Python version, it may be contentious whether this answers your question, but after a short look at ConfigParser and ConfigObj, I settled for configparser, the Python 3 version of ConfigParser. There’s also a backported version on PyPI.

    ConfigParser seemed cumbersome to me, maybe even—dare I say it—unpythonic, and with ConfigObj I encountered an esoteric problem with lists (I’d prefer to be able to align them vertically, since mine get really long), and it didn’t help that the latest version was published more than two years ago. The API of configparser, however, looked as spiffy as that of ConfigObj (albeit not as feature-rich), and when we move to Python 3, I can probably switch to the built-in version easily.

    By the way, it works great so far.

提交回复
热议问题