3 ms·
.ini configparser worked fine for decades, especially as a simple project config.
by mixmastamyk 4y ago
.ini configparser worked fine for decades, especially as a simple project config.
- barosl 4y agoPEP 518 lists some reasons not to use configparser and I agree with them wholeheartedly.[1] Personally I don't want to use ill-defined formats, even for simple projects. [1] https://peps.python.org/pep-0518/#configparser https://peps.python.org/pep-0518/#configparser
- mixmastamyk 4y agoTheir reason was obsolete shortly after it was written, Python 2 was EOL years before TOML included. Toml is ill-defined as well. ini files work fine for these trivial uses. https://hitchdev.com/strictyaml/why-not/toml/ https://hitchdev.com/strictyaml/why-not/toml/ So now you have two flawed ways to do it, congrats.
- ptx 4y agoThe only reason offered is that there are (or might be) differences between version of Python, mainly 2 and 3, as far as I can see. Python 2 is EOL, so that's no longer a concern. As for differences between Python 3 releases, isn't there a fairly large difference in TOML support as well, since in versions before 3.11 it doesn't work at all? Wouldn't specifying the behaviour of the INI parser as whatever 3.11 is doing (and raising an exception on earlier versions) amount to essentially the same thing?
- bulatb 4y agoNewer packaging-related PEPs require TOML, and many developer tools use TOML by choice, but a fresh install of Python couldn't actually read it. That required workarounds from tool and library maintainers, making it more complicated to support as many users' preferences and ways of working as possible. However you prefer to work, your tools may now be easier to test and maintain. This change is good for everyone.
- mixmastamyk 4y agoRather unnecessary. See my comment above.
- faho 4y agoThese files are already in toml, so it's only "unnecessary" if you ask for them to switch the file format. Otherwise, adding tools to the standard library to read file formats required by the ecosystem is a good idea, regardless of whether you agree with the particular format.
- digisign 4y agoThey fixed a problem that they created. History has shown that worrying about an incompatibility with the moribund Python 2 that never affected trivial packaging config was a waste of time. Meanwhile we still have a setup.cfg on a work project, has worked without issue for 15+ years.
- kkirsche 4y agoIni files aren’t a standard though, so every language can handle them differently. As a result they often bite people using them in multiple languages in the foot
- digisign 4y agoThese are dev written and Python3 read files, the parser of which hasn't changed in a decade. Everyone knows how to write them. The parser is also lenient and handles both kinds of comment. That's enough for simple metadata. We have a 15 year old setup.cfg in one project at work, many other .ini's... has never been an issue.