Python & zipfiles
Patrick Bielen
bielen at stafa.nl
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/'
os.chdir('/tmp')
zipfiles = ZipFile(zipdir + 'dbs.zip').namelist()
ZipFile(zipdir + 'dbs.zip','r')
for file in zipfiles:
print file
source = ZipFile(zipdir + 'dbs.zip').read(file)
open(file, 'w').write(source)
ZipFile(zipdir + 'dbs.zip').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-
ciated.
Greetings
Patrick
More information about the Python-list
mailing list