Python & zipfiles

Patrick Bielen bielen at
Tue Jun 25 05:53:40 EDT 2002

Hello all,

I use a module to work with zipfiles.
This one is only for unpacking files
from the zip. But i only want to know
if i have to much code to do the trick.

I'm barely new to python, that's why i ask.

--- begin script

import os
from zipfile import ZipFile

zipdir = '/as400/Beheer/Databases/'
zipfiles = ZipFile(zipdir + '').namelist()
ZipFile(zipdir + '','r')
for file in zipfiles:
    print file
    source = ZipFile(zipdir + '').read(file)
    open(file, 'w').write(source)
ZipFile(zipdir + '').close()

--- end of script ---

The problem is, that i don't know if i use the
ZipFile-command too much... because the manual
told me i have to close it afterwards, but it's
not clear to me if i have to expecitely open it.

Any help or code cleaning would be really appre-



More information about the Python-list mailing list