Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'strings.': 0.07; 'subject:skip:c 10': 0.07; 'trailing': 0.07; 'files:': 0.09; '"="': 0.16; '-tkc': 0.16; 'comma': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'key/value': 0.16; 'need,': 0.16; 'pairs': 0.16; 'quoted': 0.16; 'simple.': 0.16; 'trap': 0.16; 'wrote:': 0.16; 'config': 0.18; ';-)': 0.18; 'handles': 0.20; 'portion': 0.20; 'strip': 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'error': 0.27; 'format,': 0.27; 'said,': 0.27; 'lists?': 0.29; 'separated': 0.29; 'whitespace': 0.29; 'convention': 0.30; 'certain': 0.31; 'subject:) ': 0.32; 'usually': 0.33; 'items.': 0.33; 'point,': 0.33; 'list': 0.34; 'could': 0.35; 'project': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'wanted': 0.37; 'someone': 0.38; 'whatever': 0.39; 'application': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; "they're": 0.66; 'nicely.': 0.84; 'received:23': 0.84; 'touching': 0.84 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1438818242110:1478289503 X-MC-Ingress-Time: 1438818242110 Date: Wed, 5 Aug 2015 18:43:54 -0500 From: Tim Chase To: python-list@python.org Subject: Re: Most Pythonic way to store (small) configuration In-Reply-To: <87fv3xpfuu.fsf@elektro.pacujo.net> References: <87k2teq9tb.fsf@Equus.decebal.nl> <36333f24-3bda-4534-b22f-20c99e8d791c@googlegroups.com> <87fv3xpfuu.fsf@elektro.pacujo.net> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438818253 news.xs4all.nl 2880 [2001:888:2000:d::a6]:57647 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95043 On 2015-08-06 00:47, Marko Rauhamaa wrote: > > There's a certain simplicity to simply having key/value pairs > > separated by an "=" and then letting the application do whatever > > it needs/wants with those key/value strings. > > That trap has lured in a lot of wildlife. > > What to do with lists? > > Is whitespace significant? As I said, simple. Lists? Not in a simple config format. Though I suppose, just like the .ini format, you could use a convention of comma or space-separated list items. Or quoted white-space-separated items like shlex handles nicely. Or if you really need, pass the value portion of the key/value pair through ast.literal_eval() Significant whitespace? Not usually simple (just stuck touching a project where someone committed with tons of trailing whitespaces. grumble), so strip 'em off as if they're an error condition. I've never had a config-file where I wanted leading/trailing whitespace as significant. > Case in point, systemd configuration files: The antithesis of "simplicity" ;-) -tkc