The builtin open will always follow symlinks.
Using os.stat is the easiest solution imo.
An alternative would be using os.access but that does not raise a FileNotFoundException so I chose os.stat.
As a sidenote I'd like to mention that setting MAGIC_SYMLINK is not possible, is it?
The builtin
open
will always follow symlinks. Usingos.stat
is the easiest solution imo. An alternative would be usingos.access
but that does not raise a FileNotFoundException so I choseos.stat
.As a sidenote I'd like to mention that setting
MAGIC_SYMLINK
is not possible, is it?