For_loops hurt my brain.

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


Other possibility, combining Dan and Fredrik's posts:

import zipfile
import os

zips = {
    'c:/spare.zip': ['c:/spare/huge.fm3', 'c:/spare/huge.wk3'],
    'c:/seekfacts.zip': ['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);
    zFile.close();


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



More information about the Python-list mailing list