Check if a file is a symlink in Python


Python tip:

You can use pathlib's is_symlink() to check whether a path is a symlink.

👇

import pathlib

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

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