Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; 'subject:Python': 0.06; 'expressions': 0.07; 'mess': 0.09; 'mixed': 0.09; 'subject:module': 0.09; 'subject:skip:c 10': 0.09; 'whatever.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'constants.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'recipe': 0.16; 'subject:etc.': 0.16; 'subject:values': 0.16; 'value"': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'module': 0.19; 'file,': 0.19; 'normally': 0.19; 'examples': 0.20; 'code,': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'certainly': 0.24; 'config': 0.24; 'helpful': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'second': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'relative': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'file:': 0.31; 'subject:what': 0.31; 'trivial': 0.31; 'stuff': 0.32; 'option': 0.32; 'quite': 0.32; 'up.': 0.33; 'level.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'data,': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'seconds': 0.37; 'represent': 0.38; 'sometimes': 0.38; 'previous': 0.38; 'little': 0.38; 'easy': 0.60; 'free': 0.61; 'break': 0.61; 'simple': 0.61; 'first': 0.61; 'soon': 0.63; 'more': 0.64; 'subject:. ': 0.67; 'calculations': 0.84; 'difference.': 0.84; 'technically': 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=FBt7U4rYztU1CwVkNxpecJjUZP6KILr/PCa2mLMEIoM=; b=fQwNY3FOjvkS4jfeh/Jj0CP751LtbwDc3uSbMdUhbykT+wwsLiXpf4AJ6uISRrS7iZ l7xeJfN+KLJLAVlpBkUTBLX87/S+pHnGHC+jbSLxfQWnkdL2+DyFnClVLuA3Qm5Posx0 1AHk8IrsWSxDWjFtWKlIewVuTPczwlHpGXCCnqmYhLF3drwMac4PnuvtSii0YVkOsSsg H0DVyJGuVf7QDvXESfTt/heQXIrFNl52yGjHa01ek4PJR/yx/huf2jYTNN7ozWHF7Y6o 55dYuU9gZoW6i9gJ96Aj8S/BcUYczHU+MxlD/lGJ3rcq6EYAYA4t2pyRAzTew3Nan79w 166g== MIME-Version: 1.0 X-Received: by 10.112.61.225 with SMTP id t1mr4851688lbr.104.1412095887805; Tue, 30 Sep 2014 09:51:27 -0700 (PDT) In-Reply-To: References: <54hqfb-nan.ln1@chris.zbmc.eu> <36d7ddca-29f4-403c-a64d-611e187afc3a@googlegroups.com> Date: Wed, 1 Oct 2014 02:51:27 +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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412095890 news.xs4all.nl 2879 [2001:888:2000:d::a6]:34956 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78494 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? There's no difference. 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. ChrisA