ConfigObj quoting issues

Roopesh roopesh.raj at gmail.com
Tue Jun 3 08:25:21 CEST 2008


Hi,

I am using ConfigObj to write email addresses, as a list. I am using
email module functions to extract email addresses:

to_address = header.get_all('To', [])
address_list = getaddresses(to_address)
to = map(lambda address: '"'+address[0]+'"
<'+address[1]+'>'  ,address_list)
conf_obj['to'] = to

But quite often I am getting the error "cannot be safely quoted.".
This error is because of the presence of \', \", \n etc.

I had to do the following to make it work.
address[i].replace("\'",'').replace('\"','').replace('\n','')

[making list_all=False doesn't work properly(it fails when the first
character is a double quote). ]

I don't want to do the above, as it modifies the email address (name).
In brief, my question is how to save a list of strings which might
have quotes, double quotes to a file using ConfigObj.

Any idea what is to be done.

Thanks
Roopesh



More information about the Python-list mailing list