Reading multiline values using ConfigParser

Larry Bates larry.bates at
Thu Jun 21 17:36:16 CEST 2007

Phoe6 wrote:
> On Jun 20, 10:35 pm, "John Krukoff" <jkruk... at> wrote:
>>> Is there anyway, I can include multi-line value in the configfile? I
>> Following the link to RFC 822 (
>> indicates that you can spread values out over multiple lines as long as
>> there is a space or tab character imeediately after the CRLF.
> Thanks for the response. It did work!
>>>> config = ConfigParser()
> ['Testcases.txt']
>>>> output = config.get("Information", "Testcases")
>>>> print output
> tct123
> tct124
> tct125
>>>> output
> '\ntct123\ntct124\ntct125'
> However, as I am going to provide Testcases.txt to be "user editable",
> I cannot assume or "ask users" to provide value testcases surronded by
> spaces. I got to figure out a workaround here.
> Thanks,
> Senthil
I do this a lot and implement it as:


Then it is pretty easy to do something in my code like:

cases=[x for x in INI.options(section) if x.startswith('case_')]

for case in cases:
    casefile=INI.get(section, case)
    # Process each casefile here


More information about the Python-list mailing list