Bruce wrote:
I assume that you know the module configobj. I use it like this:
I have a config_file :
[sec1]
[[subsec1]]
a = 1
b = 2
[[subsec2]]
a = 3
b = 1
.. ans so on
Then in the code I have c = configobj.ConfigObj(path_to_config file)
then I go like for instance
for s in c['sec1']:
print c['sec1'][s]['a']
Just think its awkward that its neccessary to use the c['sec1'] again
inside the loop,
guess I`d like it to be like
print s.a
instead
Is this the right way to use configobj?
So bind a variable to the section, and write
csec = c['sec1']
for s in csec:
print csec[s]['a']
I don't think configobj support attribute-based access to the section
values, in which case
print csec[s].a
won't work.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd
http://www.holdenweb.com
Skype: holdenweb
http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------