PATH NORMALIZATION - abspath, realpath, normpath
Python
#!/usr/bin/env python3
"""PATH NORMALIZATION - abspath, realpath, normpath"""
import os, tempfile
temp = tempfile.gettempdir()
print("Path Normalization:")
rel_path = "dir/../file.txt"
print(f" Original: {rel_path}")
print(f" normpath: {os.path.normpath(rel_path)}")
print(f" abspath: {os.path.abspath(rel_path)}")
test_file = os.path.join(temp, "test.txt")
open(test_file, 'w').write("test")
print(f"\nAbsolute paths:")
print(f" abspath('test.txt'): {os.path.abspath('test.txt')}")
print(f" realpath('test.txt'): {os.path.realpath('test.txt')}")
os.remove(test_file)