section with in a section config file and reading that config file
steve+comp.lang.python at pearwood.info
Sat Oct 20 00:59:15 CEST 2012
On Fri, 19 Oct 2012 23:59:03 +0200, Tarek Ziadé wrote:
> 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:
>>>> 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
>> That is incorrect.
> uh ?
"That is incorrect" means that your statement was wrong. Configuration
files are NOT flat sequences of sections. *Some* configuration files are
flat sequences of sections, some are nested, hierarchical sections, and
some do not have sections at all.
>> A configuration file is a file containing configuration data. That is
> organized in [sections]. a flat list of sections.
No, you are making the same wrong statement.
I have hundreds of configuration files on my computer, and very few of
them are 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 :)
Who cares? Did the poster say that he needed an INI file? No he did not.
He says he needs a configuration file, and that is *much* more general
than just INI files. Not all configuration files are INI files.
The poster says he needs a list of key:value pairs split into nested
sections. Who cares if that is an INI file or not? It is still a
configuration file, and he can have such a file if he wants.
You might as well complain that his sample config was not valid Python
code. Who cares if it is not valid Python code, he didn't ask for valid
Python code, and he didn't ask for a valid INI file.
More information about the Python-list