X-Received: by 10.182.102.34 with SMTP id fl2mr42191925obb.16.1412096461376; Tue, 30 Sep 2014 10:01:01 -0700 (PDT) X-Received: by 10.50.41.103 with SMTP id e7mr126884igl.8.1412096461282; Tue, 30 Sep 2014 10:01:01 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!uq10no1245010igb.0!news-out.google.com!rp1ni7433igb.0!nntp.google.com!uq10no1245008igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Tue, 30 Sep 2014 10:01:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=59.95.28.35; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui NNTP-Posting-Host: 59.95.28.35 References: <54hqfb-nan.ln1@chris.zbmc.eu> <36d7ddca-29f4-403c-a64d-611e187afc3a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2ea96bcf-e905-4d77-a105-82b27715aa6e@googlegroups.com> Subject: Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? From: Rustom Mody Injection-Date: Tue, 30 Sep 2014 17:01:01 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:78495 On Tuesday, September 30, 2014 10:22:12 PM UTC+5:30, Chris Angelico wrote: > On Wed, Oct 1, 2014 at 2:39 AM, Rustom Mody wrote: > >> python - just keep config in the modules/classes, not easy to use > >> at 'both ends' (home and remote), otherwise quite simple > > Can work at a trivial level. > > As soon as things get a bit larger data and code mixed up is a recipe for mess up. > True, but it's certainly possible to break out the config data into an > importable module that conceptually just provides constants. > Technically it's code, yes, but it'll normally be code that looks like > your standard "name = value" config file: > # docs for first option > # more docs > # examples > # etcetera > first_option =123 > # docs for second option > second_option = 234 > Is that Python code, or is it a sectionless INI file, or what? Yeah I was going to say that this is possible > There's no difference. But there is! Its code that looks like data. > 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 I'd reiterate though what I first said: In this case its probably ok if the code (=data) does not cross trivial limits