4 ms·
A more simple and clean solution, that I always use in my python scripts: always work with absolute paths, that starts with /, and you solve all these problems.
by alerighi 8y ago
A more simple and clean solution, that I always use in my python scripts: always work with absolute paths, that starts with /, and you solve all these problems.
No reason to have relative paths outside the shell for me, relative paths are only a convenience for the shell user that doesn't have to specify the full path as an argument, but if you invoke a program from another program, it doesn't cost you nothing to pass to it as an argument the full path.
- deleted 8y ago[deleted]
- cesarb 8y agoThere are situations (most of them involving symbolic links) in which using absolute paths can change the meaning of the path. The most obvious is when creating a symbolic link, for instance a relative symbolic link from "README" to "README.md" will not break when the whole directory is moved. A more worrying one is that using absolute paths everywhere is vulnerable to TOCTOU issues, while relative paths can be less vulnerable (and can be combined with newer APIs like openat to reduce these issues further).