append special chars with "\"

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Tue Sep 30 10:29:56 EDT 2003


On Tue, 30 Sep 2003 13:33:31 +0200, rumours say that Gerrit Holl
<gerrit at nl.linux.org> might have written:

>for c in chr:
> str = str.replace(c, r"\c")

Perhaps you meant:

for c in chr:
   str = str.replace(c, r"\%s" % c)

otherwise all characters in chr would change into a literal
'backslash-c'...
-- 
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix




More information about the Python-list mailing list