Convert StringIO to string

Jonathan Bowlas me at jonbowlas.com
Mon Oct 16 09:50:55 EDT 2006


Ok, I think I'm explaining this badly because I've used getvalue() in the
script I originally submitted to the list, see below:

 

from StringIO import StringIO

 

def generator_file(rsspath,titleintro,tickeropt): 

      scripter=StringIO()

      scripter.write('<script type="text/javascript">\n')

      scripter.write('new rss_ticker(%s, %s, %s)\n' % (rsspath, titleintro,
tickeropt))

      scripter.write('</script>\n')

      return scripter.getvalue()

 

 

The problem is this script returns the following:

 

<script type="text/javascript">

new rss_ticker(www.bbc.co.uk, True, True) </script>

 

And I want to replace the < and > characters for < or > so it actually
renders correctly in a browser so I'm returned this:

 

<script type="text/javascript">

new rss_ticker(www.bbc.co.uk, True, True) </script>

 

So what am I doing wrong?

 

J

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061016/8f8748ad/attachment.html>


More information about the Python-list mailing list