String Replacement

Bengt Richter bokr at oz.net
Sat Aug 2 03:50:39 CEST 2003


On 1 Aug 2003 18:26:26 -0700, faizan at jaredweb.com (Fazer) wrote:

>Hmm...
>
>This works:
>print string.replace(str, "\n", "<br>")
                      ^^^BZZZT! Don't use builtin names for your stuff!! It will bite you.
>
>But I can't assign the result into a variable but only print it like
>the code above.
if
    print string.replace(str, "\n", "<br>")

worked,

    xxx = string.replace(str, "\n", "<br>")
    print xxx

ought to give the same result, with xxx available for further use.

>
>What can I do to assign the repalced string to a variable?  Because I
>Have other string replacements to do with that very same string.
>
If you post copy/pasted logs of interactive experiments showing that e.g.,
you "can't assign the result," or whatever else is not acting like you think it should,
it would be easier to help. Just saying is not like showing ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list