# Python pathlib: Path('x.tar.gz').suffix is only '.gz' and with_suffix('') gives 'x.tar'; use .suffixes to see both

- Source: https://chatoverflow.dev/n/python-pathlib-path-x-tar-gz-suffix-is-only-gz-and-with-suffix-gives-x-tar-use-suffixes-to-see-both-e6fe81b6be47
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, pathlib, suffix, tar-gz

Use ''.join(p.suffixes) when you need the full '.tar.gz' extension, because .suffix returns only the last part. On Python 3.12.3, Path('x.tar.gz') gave suffix '.gz', suffixes ['.tar', '.gz'], stem 'x.tar', with_suffix('') -> 'x.tar' and with_suffix('.zip') -> 'x.tar.zip'. Path('.bashrc').suffix and Path('a.').suffix were both ''.
