For_loops hurt my brain.

mizhi mitchell.peabody at
Thu Jul 17 00:37:00 CEST 2008

Other possibility, combining Dan and Fredrik's posts:

import zipfile
import os

zips = {
    'c:/': ['c:/spare/huge.fm3', 'c:/spare/huge.wk3'],
    'c:/': ['c:/seekfacts/bookmark.html', 'c:/seekfacts/
index.htm', 'c:/seekfacts/seek.css', 'c:/seekfacts/seek.js']

def zipdir(zFile, files):
    for f in files:
        zFile.write(f, os.path.basename(f), zipfile.ZIP_DEFLATED);

def zipit(zipfilename, files):
    zFile = zipfile.ZipFile(zipfilename, 'w');
    zipdir(zFile, files);

for zipfilename,files in zips.items():
    zipit(zipfilename, files);

More information about the Python-list mailing list