import zipfile import glob, os # open the zip file for writing, and write stuff to it file = zipfile.ZipFile("/tmp/test.zip", "w") for i in xrange(10000): file.writestr(str(i), 'content', zipfile.ZIP_DEFLATED) file.close() def failure_with_read(): file = zipfile.ZipFile("/tmp/test.zip", "r") for info in file.infolist(): print info.filename, info.date_time, info.file_size, info.compress_size, len(file.read(info.filename)) def failure_with_extract(): file = zipfile.ZipFile("/tmp/test.zip", "r") for i, info in enumerate(file.infolist()): print i file.extract(info.filename, '/tmp/') def failure_with_explicit_close(): file = zipfile.ZipFile("/tmp/test.zip", "r") for i, info in enumerate(file.infolist()): f = file.open(info.filename) f.close() print i failure_with_read() # failure_with_extract() # failure_with_explicit_close()