Check if file is a symlink in Python


Python tip:

You can use pathlib.Path.is_symlink to check whether the path is a symbolic link.

An example👇

import pathlib

path = pathlib.Path("/usr/bin/python")

print(path.is_symlink())
# => True