Zip File Woes
Dave Kuhlman
dkuhlman at rexx.com
Wed Jun 27 16:56:17 EDT 2007
Jerry Hill wrote:
> On 6/27/07, Robert Rawlins - Think Blue
> <robert.rawlins at thinkbluemedia.co.uk> wrote:
>> zip = zipfile.ZipFile('Media/Media.zip', '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.
Dave
--
http://www.rexx.com/~dkuhlman
More information about the Python-list
mailing list