Python example: List files in ZIP archive

This example lists all the filenames contained in a ZIP file using Python’s built-in zipfile library.

#!/usr/bin/env python3
import zipfile

def list_files_in_zip(filename):
    List all files inside a ZIP archive
    Yields filename strings.
    with zipfile.ZipFile(filename) as thezip:
        for zipinfo in thezip.infolist():
            yield zipinfo.filename
# Usage example
for filename in list_files_in_zip(""):