Python configuration file: Any file format recommendation? INI format still appropriate? Seems quite old school

前端 未结 8 1716
执念已碎
执念已碎 2020-12-04 10:43

I need to store configurations (key/value) for a Python application and I am searching for the best way to store these configurations in a file.

I run into Python\'s

相关标签:
8条回答
  • 2020-12-04 11:10

    This entirely depends on your requirements. If (as you say) all you need is key/value pairs, ini files (or other "plain" config files) will perfectly suit you. No, they are not outdated, as they are still in use.

    XML/JSON is perfect if you have hierarchical structures and also want to use more sophisticated methods (e.g: XML file validation, namespaces, etc.).

    0 讨论(0)
  • 2020-12-04 11:11

    Check out ConfigObj, its the slickest method I've found so far, and definitely more flexible than ConfigParser. Personally I'm not a fan of YAML based because its 'flexibility' makes it difficult to use with tools like Augeas.

    0 讨论(0)
提交回复
热议问题