ConfigParser & converting strings to lists

Peter Hansen peter at engcorp.com
Sat Jun 22 23:59:07 EDT 2002


"Edward K. Ream" wrote:
> Here is what I did:
> 
> s = config.get(section,"recentFiles")
> files = [x[1:-1] for x in s[1:-1].split()]
> 
> Is this what you intended?  This doesn't work for me: it "doubles" every
> backspace.

I have no idea how you're getting backspaces (\b) anywhere.  I tried 
a file that looked like your example and the above worked fine for
me.

> I am already regretting trying to be clever.  It is easy enough to set
> file individual filenames like this:
[...]
> 
> This is bulletproof: filenames can contain any character at all.  The
> only drawback is that the config file looks like:
> 
> [recent files]
> file0 = filename0
> file1 = filename1
> ...
> 
> But this isn't so bad, is it?

No, that's not bad.  In fact, I think it's pretty common.  Doing
The Simplest Thing That Could Possibly Work is generally a good strategy. :-)

-Peter



More information about the Python-list mailing list