Most Pythonic way to store (small) configuration

Ben Finney ben+python at benfinney.id.au
Sun Aug 2 21:16:09 EDT 2015


Cecil Westerhof <Cecil at decebal.nl> writes:

> On Sunday  2 Aug 2015 13:54 CEST, Ben Finney wrote:
>
> > 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.
>
> Well, I would use nested data. (A file will have extra fields besides
> the name.)

In that case, your needs are more complex than “store some simple
configuration”. You need a human-editable format (so, not JSON and not
XML) which handles structured data well, and is widely implemented.

For nested configuration data, you would be better served by YAML
<URL:https://en.wikipedia.org/wiki/YAML>, and the PyYAML library
<URL:https://pypi.python.org/pypi/PyYAML/> is the one to use.

-- 
 \                                        學而不思則罔,思而不學則殆。 |
  `\        (To study and not think is a waste. To think and not study |
_o__)             is dangerous.) —孔夫子 Confucius (551 BCE – 479 BCE) |
Ben Finney




More information about the Python-list mailing list