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?
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?
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.