ConfigParser: writes a list but reads a string?

Sybren Stuvel sybrenUSE at
Mon Jan 16 09:06:42 CET 2006

Terry Carroll enlightened us with:
> It looks like ConfigParser will accept a list to be writing to the
> *.ini file; but when reading it back in, it treats it as a string.

It doesn't say so explicitly in the manual, but I did find this:

  """The values in defaults must be appropriate for the "%()s" string

So if the defaults go through %s, perhaps all values do.

> Is there a pythonic way to read in a list from a .INI file with
> ConfigParser?

I'd pickle() the list, and store that instead. Then you can unpicle()
it and regain your list.

> I would not expect this conversion; rather, an exception when trying
> to write the list if the list is not supported.

I agree with you.

The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa

More information about the Python-list mailing list