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