Welcome to zipp documentation!

class zipp.CompleteDirs(file, mode='r', compression=0, allowZip64=True, compresslevel=None)

Bases: zipfile.ZipFile

A ZipFile subclass that ensures that implied directories are always included in the namelist.

classmethod make(source)

Given a source (filename or zipfile), return an appropriate CompleteDirs subclass.


Return a list of file names in the archive.


If the name represents a directory, return that name as a directory (with the trailing slash).

class zipp.FastLookup(file, mode='r', compression=0, allowZip64=True, compresslevel=None)

Bases: zipp.CompleteDirs

ZipFile subclass to ensure implicit dirs exist and are resolved rapidly.


Return a list of file names in the archive.

class zipp.Path(root, at='')

Bases: object

A pathlib-compatible interface for zip files.

Consider a zip file with this structure:

├── a.txt
└── b
    ├── c.txt
    └── d
        └── e.txt
>>> data = io.BytesIO()
>>> zf = zipfile.ZipFile(data, 'w')
>>> zf.writestr('a.txt', 'content of a')
>>> zf.writestr('b/c.txt', 'content of c')
>>> zf.writestr('b/d/e.txt', 'content of e')
>>> zf.filename = 'mem/abcde.zip'

Path accepts the zipfile object itself or a filename

>>> root = Path(zf)

From there, several path operations are available.

Directory iteration (including the zip file itself):

>>> a, b = root.iterdir()
>>> a
Path('mem/abcde.zip', 'a.txt')
>>> b
Path('mem/abcde.zip', 'b/')

name property:

>>> b.name

join with divide operator:

>>> c = b / 'c.txt'
>>> c
Path('mem/abcde.zip', 'b/c.txt')
>>> c.name

Read text:

>>> c.read_text()
'content of c'


>>> c.exists()
>>> (b / 'missing.txt').exists()

Coercion to string:

>>> import os
>>> str(c).replace(os.sep, posixpath.sep)

At the root, name, filename, and parent resolve to the zipfile. Note these attributes are not valid and will raise a ValueError if the zipfile has no filename.

>>> root.name
>>> str(root.filename).replace(os.sep, posixpath.sep)
>>> str(root.parent)
property filename
property name
open(mode='r', *args, pwd=None, **kwargs)

Open this entry as text or binary following the semantics of pathlib.Path.open() by passing arguments through to io.TextIOWrapper().

property parent
read_text(*args, **kwargs)

Indices and tables