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

Tarek Ziadé tarek at ziade.org
Fri Oct 19 06:09:53 EDT 2012


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

what you could do is have 2 files, and add a link from one to the other:


file1.ini:

   [AAA]
   extended = file2.ini

file2.ini:

   [BBB]
   a=1
   b=1

   [CCC]
   a=1
   b=2


then create a bit of logic on the top of ConfigParser to read back those 
values

HTH
Tarek



More information about the Python-list mailing list