Path: csiph.com!usenet.pasdenom.info!aioe.org!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'expressions': 0.07; 'agree,': 0.09; 'item.': 0.09; 'subject:module': 0.09; 'subject:skip:c 10': 0.09; 'whatever.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"from': 0.16; 'costs.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'simple.': 0.16; 'subject:etc.': 0.16; 'subject:values': 0.16; 'syntax,': 0.16; 'unambiguous': 0.16; 'url:tag': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'config': 0.24; 'own.': 0.24; 'fine': 0.24; 'helpful': 0.24; 'cc:2**0': 0.24; 'handling': 0.26; '(for': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'relative': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'subject:what': 0.31; 'trivial': 0.31; 'file': 0.32; 'probably': 0.32; 'stuff': 0.32; 'quite': 0.32; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'data,': 0.36; 'entry': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'seconds': 0.37; 'represent': 0.38; 'sometimes': 0.38; 'previous': 0.38; 'little': 0.38; 'does': 0.39; 'itself': 0.39; 'quote': 0.39; 'even': 0.60; 'most': 0.60; 'free': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; "you've": 0.63; 'decided': 0.64; 'direct': 0.67; 'subject:. ': 0.67; 'said:': 0.68; 'power': 0.76; 'calculations': 0.84; 'notably,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=TKRhcaC4OOtmx+NXAB6xT8sTGw0jlLZ2oSSNvR6Rnns=; b=VaeXE1O0iXqkU3ZzHuhYiM/eupACd5LsiZuAfYD1vjSbWUdVegH895BdksNwdgc7nJ qxWwVvT87ipbf8CHJotbN448aQImevRPf4Dwj1hC9JNqm693CPUgmmUnc23qhfyBC3op llQSWdkl6jY0LFnNpe2N9oEg9GU+KkwUodgTSfnogmWZcl+liRyVv9GgU89mqmoZ7Ln/ S8ECt7AzXjlrn4/YFLiDl1OYCeXGDpncpkfsJwcu3apkB5JVxuWOu/jLjfRUdYk3qGdN 5q+WBlmV5gDYZHqfkqnFelxJmtmBbiGlir+QUlpU78wtssJoj+ejDm4oHLwUQ8US2nx4 oklg== MIME-Version: 1.0 X-Received: by 10.152.23.69 with SMTP id k5mr49589873laf.70.1412097330457; Tue, 30 Sep 2014 10:15:30 -0700 (PDT) In-Reply-To: <2ea96bcf-e905-4d77-a105-82b27715aa6e@googlegroups.com> References: <54hqfb-nan.ln1@chris.zbmc.eu> <36d7ddca-29f4-403c-a64d-611e187afc3a@googlegroups.com> <2ea96bcf-e905-4d77-a105-82b27715aa6e@googlegroups.com> Date: Wed, 1 Oct 2014 03:15:30 +1000 Subject: Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412097338 news.xs4all.nl 2925 [2001:888:2000:d::a6]:41656 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78496 On Wed, Oct 1, 2014 at 3:01 AM, Rustom Mody wrote: >> And you get expressions for free - simple stuff like >> "7*24*60*60" to represent the number of seconds in a week (for people >> who aren't intimately familiar with 604800), or calculations relative >> to previous data, or whatever. Sometimes it's helpful to have just a >> little code in your data. > > Not free at all. Power of code means cost of code > See http://www.w3.org/2001/tag/doc/leastPower.html It's free once you've already decided (for other reasons) to make your config file use Python syntax, at which point you've already paid the cost of code. But you're quite right, allowing code does have costs. Most notably, you have to quote your strings; although the direct benefits you get (line continuation, unambiguous handling of leading/trailing spaces, etc) may outweigh that on their own. > I'd reiterate though what I first said: In this case its probably > ok if the code (=data) does not cross trivial limits I'd agree, where "trivial limits" is defined by each individual item. Going with straight Python code is fine for huge projects with long config files, as long as each config entry is itself simple. You even get a form of #include: "from otherfile import *". ChrisA