string join() method

Kent Johnson kent37 at tds.net
Thu Mar 24 13:05:53 EST 2005


Derek Basch wrote:
> Can anyone tell me why this CGI code outputs a blank page?

Maybe because it needs a blank line between the header and the body?

> --------------------------------
> self.output = []
> self.setContentType("text/plain")
> ascii_temp.seek(0)
> self.output.extend(ascii_temp.read())
self.output.append() is probably what you mean. Try this:

self.output.append('\r\n')
self.output.append(ascii_temp.read())

> print ''.join(self.output)
> 
> def setContentType(self, type="text/xml"):
>     self.output.extend(["Content-type: ", type, "\n\r"])
> ---------------------------------
> 
> but this code works?:
> ---------------------------------
> self.output = []
> self.setContentType("text/plain")
> print ''.join(self.output)
The above line will create a blank line because of the extra newline from print.

Kent

> ascii_temp.seek(0)
> print ascii_temp.read()
> 
> def setContentType(self, type="text/xml"):
>     self.output.extend(["Content-type: ", type, "\n\r"])
> ---------------------------------
> 
> ascii_temp is just some tab seperated data:
> ---------------------------------
> Allele	Seq:Start-End	Length	Sequence	Score
> A01	1: 1-8	8	SSSSSSSS	1410538.0
> A01	1: 2-9	8	SSSSSSSS	1410538.0
> ---------------------------------
> 
> Thanks everyone.
> Derek Basch
> 



More information about the Python-list mailing list