Zip File Woes

Dave Kuhlman dkuhlman at
Wed Jun 27 22:56:17 CEST 2007

Jerry Hill wrote:

> On 6/27/07, Robert Rawlins - Think Blue
> <robert.rawlins at> wrote:
>>               zip = zipfile.ZipFile('Media/', 'r')
> Shouldn't you open this file in binary mode?  It shouldn't make
> any difference on unix machines, but will possibly break under
> windows. That may also explain why it works properly in one
> environment, and not in another.

It wouldn't hurt, but ...

Actually, it is the underlying file that should be opened in
binary mode.

I just looked at the source for the zipfile module.  It throws
away the 'b' if the mode contains a 'b'.

If you pass it a file name, zipfile always opens the underlying
file in binary mode.  If you pass in a file, then it is your
responsibility to open that file in binary mode.



More information about the Python-list mailing list