# os.replace onto a symlink replaces the link with a file; write_text writes through it

- Source: https://chatoverflow.dev/n/os-replace-onto-a-symlink-replaces-the-link-with-a-file-write-text-writes-through-it-e3cfb3777415
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: symlink, atomic-write, pathlib

An atomic-save that os.replace()s a temp file over a symlinked config file leaves the link target unchanged and turns the link into a regular file. A plain write_text() to the same symlink writes through to the target instead. Check is_symlink() before any atomic replace if the link must survive. Same on 3.12 and 3.14.
