Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31774

Re: section with in a section config file and reading that config file

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tarek@ziade.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'xml,': 0.05; 'nested': 0.07; 'parser': 0.07; 'subject:file': 0.07; 'tarek': 0.07; 'python': 0.09; 'anymore.': 0.09; 'ex:': 0.09; 'file"': 0.09; 'received:internal': 0.09; 'yeah,': 0.09; 'sections': 0.13; 'file,': 0.15; 'fine.': 0.16; 'headers,': 0.16; 'introduces': 0.16; 'json,': 0.16; 'marker': 0.16; 'nesting': 0.16; 'oct': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:mail.srv.osa': 0.16; 'received:messagingengine.com': 0.16; 'received:nyi.mail.srv.osa': 0.16; 'received:osa': 0.16; 'received:srv.osa': 0.16; 'subclassing': 0.16; 'subject: \n ': 0.16; 'ziad\xc3\xa9': 0.16; 'wrote:': 0.17; 'config': 0.17; 'module,': 0.17; '>>>': 0.18; 'code,': 0.18; 'windows': 0.19; 'module': 0.19; 'parameters': 0.20; 'file.': 0.20; 'all,': 0.21; 'elements': 0.23; 'third-party': 0.23; 'cheers': 0.24; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'url:wiki': 0.26; 'am,': 0.27; 'possibly': 0.27; 'recognized': 0.27; 'strongly': 0.27; 'all.': 0.28; 'decide': 0.28; "d'aprano": 0.29; 'header,': 0.29; 'steven': 0.29; 'url:wikipedia': 0.29; 'source': 0.29; 'fri,': 0.30; 'code': 0.31; 'file': 0.32; 'structure': 0.32; 'could': 0.32; 'says': 0.33; '+0200,': 0.33; 'to:addr:python- list': 0.33; 'list': 0.35; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'data.': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'supports': 0.38; 'nothing': 0.38; 'received:10': 0.38; 'sure': 0.38; 'url:en': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'skip:u 10': 0.60; 'containing': 0.61; 'configparser': 0.84; 'ini': 0.84; 'notion': 0.84; 'anymore,': 0.95
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=pc3muOht+rNdiKG3SqZwD6 /ax+A=; b=k1RAr+awMjIX2CBKNcqS6VmaudJIUIqhA95Q4X3p3mtssjB5fFy9w8 A2gcpfPPjZrdIFTCaZ9SeHJc6vy+SUbH2KQTzVrPfpTlHGeFsW/0zqc7lCG3JMb8 V4j0UkFXQoYMHMZLZeYrHjReUxC7LrhfQJv9NXPrZF5mwgxPaP1Xk=
X-Sasl-enc +M6jtRk/hkaxBXgOrcV9qj2B9h/vsPr8ldTY/y8BK7vu 1350683944
Date Fri, 19 Oct 2012 23:59:03 +0200
From Tarek Ziadé <tarek@ziade.org>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: section with in a section config file and reading that config file
References <b5307867-0aa6-49db-b58d-803850a60d2d@googlegroups.com> <mailman.2502.1350641397.27098.python-list@python.org> <5081c620$0$30003$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <5081c620$0$30003$c3e8da3$5496439d@news.astraweb.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2537.1350683947.27098.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350683947 news.xs4all.nl 6900 [2001:888:2000:d::a6]:53714
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31774

Show key headers only | View raw


On 10/19/12 11:29 PM, Steven D'Aprano wrote:
> On Fri, 19 Oct 2012 12:09:53 +0200, Tarek Ziadé wrote:
>
>> On 10/19/12 11:51 AM, kampy wrote:
>>> hi all,
>>> my requirement is to have section with in a section in config
>>> parameters ex:
>>> [AAA]
>>>       [BBB]
>>>        a=1
>>>        b=1
>>>       [CCC]
>>>        a=1
>>>        b=2
>>> Any one help me in  understanding how to make sure that config file to
>>> have a structure like this and reading with the config parser
>> a configuration file is a flat sequences of sections, you cannot do this
> That is incorrect.
uh ?
>
> A configuration file is a file containing configuration data. That is all.
yeah,
organized in [sections]. a flat list of sections.

>
> "Configuration file" says nothing about the format of the file. It could
> be a Unix .rc file, a Windows .ini file with no section header, a
> Windows .ini file with section headers, a Python source code file, YAML,
> JSON, XML, a PLIST file, or any other format you decide to use.
>
> If the Original Poster wants an ini file with nested sections, he can
> have an ini file with nested sections.

That's not an ini file anymore. That's a Foord-file :)

There's no notion of nested sections in ini configuration files, since 
there's no syntax marker to do the nesting

see https://en.wikipedia.org/wiki/INI_file#Sections

>
> There is no support for nested sections in the ConfigParser module, but
> the ConfigObj third-party module supports it. Otherwise the OP could
> write his own code, possibly by subclassing from ConfigParser.
This is not a ini configuration file anymore, since it introduces ad-hoc 
markers added that
are not recognized by other parsers.

Which is fine.

But instead of using an exotic, ad-hoc, look-alike ini file,
I strongly recommend using a standard that has native nested elements 
(json or yaml)

Cheers
Tarek

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

section with in a section config file and reading that config file kampy <narasimha18sv@gmail.com> - 2012-10-19 02:51 -0700
  Re: section with in a section config file and reading that config file Tarek Ziadé <tarek@ziade.org> - 2012-10-19 12:09 +0200
    Re: section with in a section config file and reading that config file narasimha18sv@gmail.com - 2012-10-19 03:22 -0700
      Re: section with in a section config file and reading that config file Tarek Ziadé <tarek@ziade.org> - 2012-10-19 15:57 +0200
        Re: section with in a section config file and reading that config file rusi <rustompmody@gmail.com> - 2012-10-19 07:26 -0700
    Re: section with in a section config file and reading that config file narasimha18sv@gmail.com - 2012-10-19 03:22 -0700
    Re: section with in a section config file and reading that config file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-19 21:29 +0000
      Re: section with in a section config file and reading that config file Tarek Ziadé <tarek@ziade.org> - 2012-10-19 23:59 +0200
        Re: section with in a section config file and reading that config file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-19 22:59 +0000
  Re: section with in a section config file and reading that config file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-19 17:46 -0400

csiph-web