Reading multiline values using ConfigParser
Carsten Haese
carsten at uniqsys.com
Thu Jun 21 09:03:03 EDT 2007
On Thu, 2007-06-21 at 02:51 +0000, Phoe6 wrote:
> On Jun 20, 10:35 pm, "John Krukoff" <jkruk... at ltgc.com> wrote:
>
> > > Is there anyway, I can include multi-line value in the configfile? I
>
> >
> > Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html)
> > 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()
> >>> config.read("Testcases.txt")
> ['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.
Since you don't actually need a multi-line entry but rather a list of
single-line entries, you could ask your users to enter something like
this:
TestcaseCount=3
Testcase1=tct123
Testcase2=tct124
Testcase3=tct125
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list