'Get the mtime of a symlink and not its target in Python
In Python (and Python2) on macOS, when I use
os.path.getmtime('/path/to/a/symlink')
I get the modification time of the symlink's target. - How do I get instead the modification time of the symlink itself?
Solution 1:[1]
As @LeiYang hinted in a comment, use os.lstat instead.
However, the result is not an mtime float, but rather a stat_result structure.
How to extract the mtime information see stat — Interpreting stat() results in the Python documentation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | halloleo |
