newbie problem with files...

Bjoern google at blinker.net
Mon May 27 19:36:43 EDT 2002


I've received the answers now. One part is to open files for reading
in binary mode. For cgi-scripts, I also found it necessary to add the
-u option to the execution of python scripts, as I am using windows.
That was in a faq-entry from 1997 - wouldn't it make sense to make
that the default behaviour on windows?


Bjoern


google at blinker.net (Bjoern) wrote in message news:<a5d863b1.0205271027.73b02349 at posting.google.com>...
> Hello,
> 
> I can't seem to read complete files, they are usually cropped after
> 1Kb or so. I've tried with file upload in cgi, but also reading files
> from disk directly and writing them to another file.
> 
> The only thing I could imagine is that it has to do with the
> description of read():
> 
> "For certain files, like ttys, it makes sense to continue reading
> after an EOF is hit."
> 
> I don't know what a ttys is - so how would I know when to continue
> reading after an EOF, and how would I then know when to stop?
> 
> My current testcode goes like this
> 
> fIn = open("doublebuffer.zip","r")
> fOut = open("double2.zip","wb")
> 
> chunk = fIn.read()
> fOut.write(chunk)
> fOut.flush()
> fOut.close()
> fIn.close()
> 
> where doublebuffer.zip is a 13Kb zipfile. double2.zip ends up a 1KB
> file that isn't a valid zip-file...
> 
> Many thanks in advance for any pointers!
> 
> 
> Bjoern



More information about the Python-list mailing list