ConfigParser & converting strings to lists

Edward K. Ream edream at tds.net
Sat Jun 22 21:53:44 EDT 2002


Hi all,

I have a question concerning lists in the ConfigParser module.  What I
would like to do is something like:

config = ConfigParser.ConfigParser()
config.set("recent files", "recentFiles, files)

where files is a _list_ of file names.  Actually, this works just fine,
and the config file contains:

[recent files]
recentFiles = [file1, file2, ...]

as expected.  However,

files = config.get("recent files", "recentFiles")

sets files to the _string_ "[file1, file2, ...]".  I suppose this must
be how get should work; after all, settings could be arbitrary
strings...

Anyway, I wonder whether there is a clever way of converting the string
representation of a list containing strings into a true list of
strings.  In any event, wouldn't a getlist convenience method be nice?

Thanks!

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edream at tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html
--------------------------------------------------------------------



More information about the Python-list mailing list