Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: cl@isbd.net Newsgroups: comp.lang.python Subject: Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Date: Tue, 30 Sep 2014 16:06:19 +0100 Lines: 58 Message-ID: References: <54hqfb-nan.ln1@chris.zbmc.eu> <36d7ddca-29f4-403c-a64d-611e187afc3a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net FaUxEc3HEkBmbHvjDuL3/QoGj/O5Jt/o/oEmkcJSPo/DtCFYo= X-Orig-Path: not-for-mail Cancel-Lock: sha1:xgAVnwAxkMwKbqvyCs2zXjlcFlY= User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (Linux/3.13.0-36-generic (x86_64)) Xref: csiph.com comp.lang.python:78490 Rustom Mody wrote: > On Tuesday, September 30, 2014 5:18:31 PM UTC+5:30, Chris wrote: > > > I would actually > > quite like to keep the configuration data separate from the code as it > > would simplify using the data at the 'home' end of things as I'd just > > need to copy the configuration file across. This was why the database > > approach appealed at first as all I need to do is copy the database > > and everything is in there. > > Of course > > > Are there any better ways of doing this? E.g. some sort of standard > > configuration file format that Python knows about? > > Umm this is getting to be a FAQ... > Maybe it should go up somewhere? > > Yes there are dozens: > - ini > - csv > - json > - yml > - xml > - pickle > - And any DBMS of your choice > > I guess Ive forgotten as many as Ive listed!! Yes, I know, I've found most of those. I'm really asking for help in choosing which to use. I think I can reject some quite quickly:- ini - doesn't work so well with lists/dictionaries (though possible) csv - rather difficult to edit json - one of the most likely possibilities, but prefer yml yml - front runner if I go for configuration files xml - horrible, nasty to edit, etc. I don't like XML! :-) pickle - not user editable as I understand it dbms - current solution in sqlite3 as described What I'm really asking for is how to choose between:- DBMS - present solution, keeps config with data easily but more code and less easy to change yml - easy to edit config, keeps data separate from code but needs YAML installed and separate files to manage python - just keep config in the modules/classes, not easy to use at 'both ends' (home and remote), otherwise quite simple My requirements are:- Easy to change, i.e.human readable format which can be edited simply as I have to do this via a terminal/ssh. Easy to use at local end as well as remote end, the remote end is where it lives and is the 'driver' as it were but I need to know the configuration at the local end as well. -- Chris Green ยท