Using python in CGI

Sheila King usenet at thinkspot.net
Sun Feb 23 12:43:34 EST 2003


On Sun, 23 Feb 2003 08:40:36 -0800, Sheila King <usenet at thinkspot.net>
wrote in comp.lang.python in article <b3a1e4.v8.1 at kserver.org>:

> CGI just prints whatever you output to the browser. I'm not sure what
> you're distinction is between "raw" and ASCII.
> 
> In general:
> 
> >>> f = open(filename, "w")
> >>> f.write()
> 
> Would output the contents of the file to the browser in a CGI script.


GAHHHH!!!!

This is a gross error, and I plead not having had my coffee yet. Should
always have coffee first on Sunday morning before posting in reply to
assistance requests.

Um, the above example will certainly NOT do what it claims. In fact, it
will "overwrite" the file with nothing, and then generate an error.

Ummmm...how about this instead?

>>> f = open(filename, "r")
>>> print f.read()

geeeez.

I apologize for earlier misinformation.

/me goes to get refill on coffee...


-- 
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




More information about the Python-list mailing list