Jan-31-2018, 09:42 PM
(Jan-31-2018, 02:59 PM)DeaD_EyE Wrote: This snippet works:
def list_zip(file, filename=None): zf = zipfile.ZipFile(file, 'r') for cf in zf.filelist: print(zf.filename or filename, cf.filename, sep=': ') if cf.filename.lower().endswith('.zip'): with zf.open(cf.filename, 'r') as new_zf: list_zip(io.BytesIO(new_zf.read()), cf.filename)The argument filename is only used to hand over the recursive call the current name of the open zip file.
The error-handling is your task :-P
SO COOL!!!!!
OK, that's just fricken amazing! :)
Did you have this code mostly figured out or I'm assuming you've worked with nested zip files before?
I was finally able to get my version working with recursively extracting, then processing that tree, but yours is so much cleaner.
I'm new to Python, but still humbled by your amazing reply and code.
Thanks very much.
- O