Skip to content
Shihao Qi
Projects
Writing
Notes
Search
About
中
TAG
File Paths
Everything filed under this tag.
1 entries
01
Writing
Computing the project root twice: Path(__file__).parents[N] silently points elsewhere once the file moves
2026-10-19
Finding the project root by counting levels up from __file__ is a second copy of where the file lives, and it doesn’t update when the file moves or the snippet is copied to a different depth. In Autarkia one module wrote its data into an auto-created directory under core/, froze the old data, and never raised an error.
#Python
#Single Source of Truth
#File Paths
← All tags
Search the site