ConfigParser options spanning more than one line

Paramjit Oberoi p_s_oberoi at hotmail.com
Mon Aug 16 14:31:03 EDT 2004


> 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



More information about the Python-list mailing list