[Python-Dev] ConfigParser with a single section
Guido van Rossum
guido@python.org
Fri, 08 Nov 2002 11:55:44 -0500
> Unfortunately I cannot easily supply the section line when parsing the
> config file, even if I use ConfigParser.readfp(); the "obvious solution"
>
> prefix = cStringIO.StringIO("[Options]\n")
> cfp = ConfigParser.ConfigParser()
> cfp.readfp(prefix, filename)
> cfp.read(filename)
>
> doesn't work because the ConfigParser object expects a new section header
> for each read*() call.
So copy everything into one memory buffer.
--Guido van Rossum (home page: http://www.python.org/~guido/)