|
From: Stef M. <s.m...@ru...> - 2007-09-26 21:30:17
|
Michael Foord wrote: > Stef Mientki wrote: > >> [snip..] >> Now my problem is very-very simple, >> but I don't get it done, >> so maybe someone get give me a few simple ;-) hints. >> >> I open an ini-file for reading: >> ini = ConfigObj ( filename ) >> >> >> I want to see what sections are ther: >> ini.sections >> >> Now I want to see what keys are in 1 specific sections: >> ?????? >> things like >> ini.values() >> ini.items() >> >> > > thanks Michael, > ini.keys() > but that gives me the section names, so it's the same as ini.sections > or > > ini[section_name].keys() > aha that's what I'm looking for. > ConfigObj has a 'dictionary interface' - so all the methods available on > a normal Python dictionary can be used with ConfigObj. > > Simple enough? > Yes that's indeed not too difficult ;-) the reason why I've so much trouble with this, is probably that I (almost) never use dictionaries. Still one other small question, which must be peanuts for you (and others), how do I read a value as a normal string ? When I've an inifile with following content: size = (134,433) ConfigObj gives me back a list ['(134', '433)'] Undoubtedly usefull in most cases (although the brackets look weird to me ;-), but as I move around and manipulate these "things" all over in my program, I just want to handle 1 type, for which I've chosen the string type. cheers, Stef |