Most Pythonic way to store (small) configuration

Cecil Westerhof Cecil at decebal.nl
Sun Aug 2 12:51:00 EDT 2015


On Sunday  2 Aug 2015 13:54 CEST, Ben Finney wrote:

> Cecil Westerhof <Cecil at decebal.nl> writes:
>
>> Because of this I think a human readable file would be best.
>
> I agree with that criterion; in the absence of compelling reasons
> otherwise, human-readable and -editable text is a good default.
>
>> Personally I do not find XML very readable. So a conf or json file
>> looks the most promising to me. And I would have a slight
>> preference for a json file.
>
> XML and JSON should both be considered data serialisation formats
> only.
>
> JSON is human-readable to an extent, but it is quite brittle, and
> there are no comments permitted in the syntax.
>
> So, both XML and JSON should be considered write-only, and produced
> only for consumption by a computer; they are a poor choice for
> presenting to a human.
>
> The “INI” format as handled by the Python ‘configparser’ module is
> what I would recommend for a simple flat configuration file. It is
> more intuitive to edit, and has a conventional commenting format.

Well, I would use nested data. (A file will have extra fields besides
the name.) That is why I was thinking about json. But I will look into
it.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list