Python search and replace in StringIO buffer?
<p>I'm using <a href="http://docs.python.org/library/telnetlib.html" rel="nofollow">telnetlib</a> to get a few lines of text (tn = telnetlib).</p>

<pre><code>o = cStringIO.StringIO(tn.read_all())

# this prints the entire text as it should (a few lines)
print o.getvalue()
o.close()
</code></pre>

<p>Now, is there a way to search based on a string and replace an entire line in the cStringIO buffer if the string is found?
I did this with files on disk, but it's not very organised. The code is a mess and I need a lot of temporary files, I need to make a lot of search and replace operations.</p>
