Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94904
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.03; 'json': 0.05; 'default.': 0.07; 'linear': 0.07; 'subject:skip:c 10': 0.07; 'snippet': 0.09; 'python': 0.10; 'weird': 0.15; '(small)': 0.16; '>on': 0.16; 'advocating': 0.16; 'files...': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'quoted': 0.16; 'readable': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'shallow': 0.16; 'simpson': 0.16; 'structure.': 0.16; 'wrote:': 0.16; 'nested': 0.18; 'skip': 0.18; '>>>': 0.20; '2015': 0.20; 'aug': 0.20; 'otherwise,': 0.20; 'cheers,': 0.22; 'file.': 0.22; 'bruce': 0.23; 'header:In-Reply- To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'parameters': 0.27; 'scale': 0.27; 'embed': 0.29; 'handled': 0.29; 'skip:[ 10': 0.31; 'probably': 0.31; 'subject:) ': 0.32; 'received:com.au': 0.33; 'rule': 0.33; 'skip:/ 20': 0.33; 'structure': 0.34; 'file': 0.34; 'could': 0.35; 'text': 0.35; 'besides': 0.35; 'i.e.': 0.35; 'quite': 0.35; 'something': 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; '(and': 0.36; 'basic': 0.36; 'data.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'agree': 0.37; 'green': 0.38; 'names': 0.38; 'stuff': 0.38; 'log': 0.38; 'several': 0.38; 'mean': 0.38; 'why': 0.39; 'data': 0.39; 'format': 0.39; 'does': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'some': 0.40; 'easy': 0.60; 'reach': 0.61; 'school': 0.62; 'course': 0.62; 'flat': 0.63; 'more': 0.63; 'within': 0.64; 'cameron': 0.66; 'incorporate': 0.66; 'skip:\xe2 10': 0.70; 'sunday': 0.72; 'barber': 0.84; 'cecil': 0.84; 'commenting': 0.84; 'compelling': 0.84; 'complexity': 0.84; 'eg:': 0.84; 'fields,': 0.84; 'hole,': 0.84; 'ini': 0.84; 'roman': 0.84; 'westerhof': 0.84; '8bit%:33': 0.91; 'tricky': 0.93 |
| Date | Mon, 3 Aug 2015 08:49:30 +1000 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | python-list@python.org |
| Subject | Re: Most Pythonic way to store (small) configuration |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| In-Reply-To | <87fv41r5vv.fsf@Equus.decebal.nl> |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| References | <87fv41r5vv.fsf@Equus.decebal.nl> |
| X-Optus-CM-Score | 0 |
| X-Optus-CM-Analysis | v=2.1 cv=XMDNMlVE c=1 sm=1 tr=0 a=7VRakydLWw4CnqwyGz1TSg==:117 a=7VRakydLWw4CnqwyGz1TSg==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=vrnE16BAAAAA:8 a=yEdEr6MRgwAA:10 a=IkcTkHD0fZMA:10 a=uRRa74qj2VoA:10 a=zLr-PlEfOKFXcPmdpvUA:9 a=QEXdDO2ut3YA:10 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1160.1438555783.3674.python-list@python.org> (permalink) |
| Lines | 77 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1438555783 news.xs4all.nl 2844 [2001:888:2000:d::a6]:49510 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:94904 |
Show key headers only | View raw
On 02Aug2015 18:51, Cecil Westerhof <Cecil@decebal.nl> wrote:
>On Sunday 2 Aug 2015 13:54 CEST, Ben Finney wrote:
>> Cecil Westerhof <Cecil@decebal.nl> writes:
>>> Because of this I think a human readable file would be best.
>>
>> I agree with that criterion; in the absence of compelling reasons
>> otherwise, human-readable and -editable text is a good default.
[...]
>> The “INI” format as handled by the Python ‘configparser’ module is
>> what I would recommend for a simple flat configuration file. It is
>> more intuitive to edit, and has a conventional commenting format.
>
>Well, I would use nested data. (A file will have extra fields besides
>the name.) That is why I was thinking about json. But I will look into
>it.
Like others, I also recommend an INI file. You can always move to something
more complex (and harder to edit) if it doesn't work out.
Note that "nested data" does not rule out an INI file unless you mean
"recursive" data or quite a deep nesting of structure. Shallow structure (one
or two levels) is very easy to embed in the INI format.
Eg:
[main]
this = that
size = 10
directory = /path/to/default/dir
[gui]
foreground = green
style = baroque
[*.log]
stuff about log files...
[/path/to/file1]
title = something
param1 = 5
param2 = 6
fields = column2, column7
[column2:/path/to/file1]
format = numeric
scale = logarithmic
[column7:/path/to/file1]
format = roman
scale = linear
See that by being a little tricky about the section names you can incorporate a
fair degree of structure? I would not advocating going too fair down that
rabbit hole, but for basic stuff it works well.
And of course you can put structure within a section:
[foo]
complexity = {'blah': 'blah blah', 'frib': {'frob': 1, 'frab': 2}}
format_width = 10
format_style = right-justified
format_dialect = quoted
i.e. you could put (small) JSON snippet in some fields, or present a few
parameters to describe "format".
There are several ways to do this kind of thing before reaching for more
complex syntaxes. Just don't let it get too weird - that would probably be a
sign you do want to reach for JSON or YAML.
But start with INI. Simple and easy.
Cheers,
Cameron Simpson <cs@zip.com.au>
A squealing tire is a happy tire.
- Bruce MacInnes, Skip Barber Driving School instructor
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Most Pythonic way to store (small) configuration Cecil Westerhof <Cecil@decebal.nl> - 2015-08-02 12:11 +0200
Re: Most Pythonic way to store (small) configuration Chris Angelico <rosuav@gmail.com> - 2015-08-02 20:49 +1000
Re: Most Pythonic way to store (small) configuration Ben Finney <ben+python@benfinney.id.au> - 2015-08-02 21:54 +1000
Re: Most Pythonic way to store (small) configuration Cecil Westerhof <Cecil@decebal.nl> - 2015-08-02 18:51 +0200
Re: Most Pythonic way to store (small) configuration Lele Gaifax <lele@metapensiero.it> - 2015-08-02 22:02 +0200
Re: Most Pythonic way to store (small) configuration Cameron Simpson <cs@zip.com.au> - 2015-08-03 08:49 +1000
Re: Most Pythonic way to store (small) configuration Ben Finney <ben+python@benfinney.id.au> - 2015-08-03 11:16 +1000
Re: Most Pythonic way to store (small) configuration Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-02 16:12 +0100
Re: Most Pythonic way to store (small) configuration Tim Chase <python.list@tim.thechases.com> - 2015-08-02 16:11 -0500
Re: Most Pythonic way to store (small) configuration Dan Sommers <dan@tombstonezero.net> - 2015-08-03 04:02 +0000
Re: Most Pythonic way to store (small) configuration Steven D'Aprano <steve@pearwood.info> - 2015-08-03 23:38 +1000
Re: Most Pythonic way to store (small) configuration Chris Angelico <rosuav@gmail.com> - 2015-08-03 23:46 +1000
Re: Most Pythonic way to store (small) configuration Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-03 15:37 +0100
Re: Most Pythonic way to store (small) configuration marco.nawijn@colosso.nl - 2015-08-04 07:53 -0700
Re: Most Pythonic way to store (small) configuration Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-08-04 19:06 +0200
Re: Most Pythonic way to store (small) configuration marco.nawijn@colosso.nl - 2015-08-04 11:37 -0700
Re: Most Pythonic way to store (small) configuration Ben Finney <ben+python@benfinney.id.au> - 2015-08-05 05:59 +1000
Re: Most Pythonic way to store (small) configuration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-08-05 18:32 +1000
Re: Most Pythonic way to store (small) configuration Chris Angelico <rosuav@gmail.com> - 2015-08-05 20:01 +1000
Re: Most Pythonic way to store (small) configuration Michael Torrie <torriem@gmail.com> - 2015-08-04 19:32 -0600
Re: Most Pythonic way to store (small) configuration Grant Edwards <invalid@invalid.invalid> - 2015-08-05 14:00 +0000
Re: Most Pythonic way to store (small) configuration random832@fastmail.us - 2015-08-04 22:44 -0400
Re: Most Pythonic way to store (small) configuration Michael Torrie <torriem@gmail.com> - 2015-08-04 22:48 -0600
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-04 21:55 -0700
Re: Most Pythonic way to store (small) configuration Lele Gaifax <lele@metapensiero.it> - 2015-08-05 08:54 +0200
Re: Most Pythonic way to store (small) configuration Tim Chase <python.list@tim.thechases.com> - 2015-08-05 08:18 -0500
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-05 06:37 -0700
Re: Most Pythonic way to store (small) configuration Tim Chase <python.list@tim.thechases.com> - 2015-08-05 15:55 -0500
Re: Most Pythonic way to store (small) configuration Marko Rauhamaa <marko@pacujo.net> - 2015-08-06 00:47 +0300
Re: Most Pythonic way to store (small) configuration Tim Chase <python.list@tim.thechases.com> - 2015-08-05 18:43 -0500
Re: Most Pythonic way to store (small) configuration Chris Angelico <rosuav@gmail.com> - 2015-08-06 10:07 +1000
Re: Most Pythonic way to store (small) configuration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-08-06 17:33 +1000
Re: Most Pythonic way to store (small) configuration Chris Angelico <rosuav@gmail.com> - 2015-08-06 17:51 +1000
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-05 18:01 -0700
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-05 18:06 -0700
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-05 06:46 -0700
Re: Most Pythonic way to store (small) configuration Steven D'Aprano <steve@pearwood.info> - 2015-08-06 00:08 +1000
Re: Most Pythonic way to store (small) configuration Rustom Mody <rustompmody@gmail.com> - 2015-08-05 07:25 -0700
csiph-web