Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'module)': 0.09; 'parameter': 0.09; 'subject:files': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'refactoring': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'input': 0.22; 'cc:addr:python.org': 0.22; 'config': 0.24; 'decide': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'define': 0.26; 'pass': 0.26; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'possibility': 0.29; 'usually': 0.31; 'allows': 0.31; 'file': 0.32; 'another': 0.32; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'done': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'subject:" ': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'information': 0.63; 'subject:The': 0.64; 'become': 0.64; 'more': 0.64; 'afraid': 0.65; 'to:addr:gmail.com': 0.65; 'received:50.22': 0.84 Date: Sat, 9 Aug 2014 12:08:23 -0500 From: Tim Chase To: Fabien Subject: Re: The "right" way to use config files In-Reply-To: References: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407604196 news.xs4all.nl 2839 [2001:888:2000:d::a6]:60011 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75950 On 2014-08-09 13:48, Fabien wrote: > So I had the idea to define a super-object which parses the config > file and input data and is given as a single parameter to the > processing functions, and the functions take the information they > need from it. This is tempting because there is no need for > refactoring when I decide to change something in the config, but I > am afraid that the program may become unmaintainable by someone > else than myself. Another possibility would be at least to give all > the functions access to the configfile. > > To get to the point: is it good practice to give all elements of a > program access to the configfile and if yes, how is it done > "properly"? Though I don't like how it looks/feels to pass around the config in just about any function-call that needs it, I've found that doing so allows me to test more readily. The alternative (putting it in a global or some module) usually means that it's harder for me to test in isolation. -tkc