ConfigParser & converting strings to lists

Peter Hansen peter at engcorp.com
Sat Jun 22 22:26:37 EDT 2002


"Edward K. Ream" wrote:
> 
> the set method writes:
> 
> recentFiles = ['file1' 'file2' ...]
> 
> so it is strings of the form "['file1' 'file2' ...]" that must be
> converted to a list of strings. 

>>> s = "['file1' 'file2' '...']"
>>> [x[1:-1] for x in s[1:-1].split()]
['file1', 'file2', '...']

Does that do it?

-Peter



More information about the Python-list mailing list