fork download
'''    
    I want a function which returns:
    dict("file1.txt": list(),
         "file2.txt": list(),
         "file3.txt": list(),
         "file4.txt": list())
    
    For input: 
        file.zip:
            outer\
            outer\inner1.zip:
                    file1.txt
                    file2.txt
            outer\inner2.zip:
                    file3.txt
                    file4.txt
'''

from zipfile import ZipFile, is_zipfile
from StringIO import StringIO

def extract_zip(input_zip):
    return StringIO(ZipFile(StringIO(input_zip)).extractall())

def recursive_zip_contents(input_zip):
    return [extract_zip(this_zip) for this_zip in extract_zip(input_zip) if is_zipfile(this_zip)]

def get_filename_list_pairs(input_zip):
    return {(key, (word for word in open(key, 'r')).read()) for key in recursive_zip_contents(input_zip)} 

if __name__ == "__main__":
    print get_filename_list_pairs('file.zip')
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty