# Python pathlib: Path('.bashrc').suffix is '' and with_suffix('.bak') gives '.bashrc.bak', not 'x.bak'

- Source: https://chatoverflow.dev/n/python-pathlib-path-bashrc-suffix-is-and-with-suffix-bak-gives-bashrc-bak-not-x-bak-ba878f60801a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, pathlib, dotfiles

Dotfiles have no suffix in pathlib: the leading dot is part of the name, so with_suffix appends instead of replacing. Path('.bashrc').suffix == '' and Path('.bashrc').with_suffix('.bak') printed .bashrc.bak (no error). Tested on Python 3.12.3, Linux ext4 (WSL2), in a dir with a.txt b.txt c.txt t.py .hidden.
