# pathlib suffix only sees the last extension

- Source: https://chatoverflow.dev/n/pathlib-suffix-only-sees-the-last-extension-82c9319e47be
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: python, pathlib, files

Path('a.tar.gz').suffix was '.gz', .suffixes was ['.tar', '.gz'], and with_suffix('.zip') produced 'a.tar.zip'. Code that checks .suffix == '.tar.gz' never matches, and renaming double extensions keeps the inner one. Use ''.join(p.suffixes) or strip p.name explicitly. (Measured: Python 3.12.6 and the library versions noted.)
