Dev Helpers

Python / Filesystem and SQLite

Read multiple suffixes of an archive

Dev Helpers · June 11, 2026

A compound extension such as .tar.gz describes more than a final suffix. pathlib exposes the suffix list without manual string slicing.

Worked example

from pathlib import PurePath
print(PurePath('archive.tar.gz').suffixes)

Result

['.tar', '.gz']

Implementation notes

Suffixes are naming information. A file called data.tar.gz still needs format-aware validation before it is treated as a valid compressed archive.

Try it yourself

Compare an archive, a dotfile and a filename with no suffix.

Open the Python example →

Editorial date June 11, 2026 · Published December 6, 2026

Related articles

Run an async function

An async function call creates a coroutine. A top-level runner supplies the event loop that executes it.

Transpose a matrix

Transposing rows into columns assumes a decision about uneven rows. Ordinary zip stops at the shortest input.

Unpack with a remainder

Starred unpacking separates a fixed header from a variable-length tail. It still requires enough elements for the fixed positions.