<html>
<body>
At 03:00 PM 8/1/2003 -0700, Fazer wrote:<br>
<blockquote type=cite class=cite cite>[snip] I am sort of confused
in<br>
using the string modules and its functions/modules to replace the 
\n<br>
with <br>.  I import the string module and I am not soo sure
on how to<br>
do the replacing.<br><br>
Here's how my code sort of likes:<br><br>
import string<br>
string.replace(DataFromDatabase, "\n",
"<br>")<br><br>
Unfortunately, it doesn't work.</blockquote><br>
Actually, it does work. Just not in the way you expect. Read the
documentation:<tt><a name="l2h-134"></a>replace</tt>(old,
new<font size=4>[</font>, maxsplit<font size=4>]</font>) 
<dl>
<dd>Return a copy of the string with all occurrences of substring old
replaced by new....
</dl>string.replace is returning the altered copy; your program is not
doing anything with it.<br><br>
What you want is to take the returned value and assign it to
DataFromDatabase:<br>
DataFromDatabase = string.replace(DataFromDatabase, "\n",
"<br>")<br><br>
BUT also realize that most of the string module functions are now string
methods, so it is possible (and simpler) to write:<br>
DataFromDatabase = DataFromDatabase.replace("\n",
"<br>")<br><br>
If you develop further needs for substitutions you'd want to consider
alternate techniques rather than stacking up a lot of replace
calls.<br><br>
OTOH some methods do operate "in-place" such as
listobject.sort() and listobject.reverse().<br>
<x-sigsep><p></x-sigsep>
Bob Gailer<br>
bgailer@alum.rpi.edu<br>
303 442 2625<br>
</body>
</html>