Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'url:pypi': 0.03; 'json': 0.05; 'subject:skip:c 10': 0.07; 'implemented.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'xml)': 0.09; '(so,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'yaml': 0.16; 'wrote:': 0.16; 'nested': 0.18; 'library': 0.20; '2015': 0.20; 'aug': 0.20; 'handles': 0.20; 'xml': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'data,': 0.27; 'consumption': 0.29; 'url:wikipedia': 0.29; 'url:wiki': 0.30; 'subject:) ': 0.32; 'url:python': 0.33; 'case,': 0.34; 'file': 0.34; 'so,': 0.35; 'besides': 0.35; 'widely': 0.35; 'should': 0.36; 'url:org': 0.36; 'data.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'data': 0.39; 'format': 0.39; 'url:en': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'more': 0.63; '8bit%:100': 0.70; 'study': 0.70; 'sunday': 0.72; '\xe2\x80\x93': 0.72; '_o__)': 0.84; 'cecil': 0.84; 'received:125': 0.84; 'skip:\xe5 40': 0.84; 'waste.': 0.84; 'westerhof': 0.84; '8bit%:18': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Most Pythonic way to store (small) configuration Date: Mon, 03 Aug 2015 11:16:09 +1000 References: <87k2teq9tb.fsf@Equus.decebal.nl> <87fv41r5vv.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:ZbFPyl8eSyK4uD2txbeGvw8CzPY= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438564587 news.xs4all.nl 2833 [2001:888:2000:d::a6]:34211 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:94910 Cecil Westerhof 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 , and the PyYAML library 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