ConfigParser options spanning more than one line

Josh Close narshe at gmail.com
Mon Aug 16 14:57:30 EDT 2004


That works, I guess I'll just have to remove the \n from the variable then.

-Josh

On Mon, 16 Aug 2004 13:31:03 -0500, Paramjit Oberoi
<p_s_oberoi at hotmail.com> wrote:
> > I'm using ConfigParser and I can't seem to get a config option to span
> > more than one line.
> 
> >>> from ConfigParser import ConfigParser
> >>> from StringIO import StringIO
> >>> s = StringIO("[a]\n"
> ....              "b = 123\n"
> ....              " 456")
> >>> c=ConfigParser()
> >>> c.readfp(s)
> >>> c.get('a','b')
> '123\n456'
> 
> In other words, any line with a leading whitespace is considered a
> continuation line, and the leading whitespace is stripped from the value
> (but the carriage return is left in).
> 
> HTH,
> -param
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list