Newbie question - zipfile module syntax

Alex Martelli aleaxit at yahoo.com
Tue Jun 12 18:01:04 EDT 2001


"Michael Davis" <michael at damaru.com> wrote in message
news:3B267B95.9BDA676 at damaru.com...
    ...
> This creates the zipfile, but doesn't compress it. The spec says that
> you can add a third argument, either ZIP_DEFLATED or ZIP_STORED as a 3rd
> argument to the constructor.
>
> I assume these are meant to be strings. When I try to write the second

Wrong!  Look:

>>> import zipfile
>>> dir(zipfile)
['BadZipfile', 'PyZipFile', 'ZIP_DEFLATED', 'ZIP_STORED', 'ZipFile',
'ZipInfo',
    [snip snip]
>>> print zipfile.ZIP_DEFLATED
8
>>>

See?  ZIP_DEFLATED is an attribute of the module zipfile and its
value happens to be the number 8.


Alex






More information about the Python-list mailing list