`readlink -m` equivalent function in Python to get canonical file name
How to Get the Canonical File Name in Python (readlink -m) The Linux command readlink -m resolves a path to its absolute, canonical form, following all symlinks and resolving .. or . components. In Python, we have a direct equivalent. The Python Equivalent: os.path.realpath() import os canonical_path = os.path.realpath(“./../folder/./file.txt”) The Modern pathlib Way from pathlib…