ConfigObj quoting issues

TheSaint fc14301589 at icqmail.com
Tue Jun 3 11:02:43 CEST 2008


On 14:25, martedì 03 giugno 2008 Roopesh wrote:

> 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','')
> 
it's rather ugly :)
I suggest use re module as follow:

import re
address[i] = re.sub('(`|"|\n)',re.MULTILINE,address[i])

if you've a big chunck of email it'd be fine to compile the regex.

match = re.compile(`|"|\n)
address[i] = match.sub(address[i])

I think there would be a problem with unicode email addresses. But I doubt
the existance of unicode addresses nowadays.
Unsure for the syntax, pls check
http://www.python.org/doc/2.4/lib/re-syntax.html
                          ^^^ according your version, but they're quite the
same

-- 
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html



More information about the Python-list mailing list