Python pathlib.Path.expanduser()


Python tip:

You can use Path.expanduser from pathlib to convert ~ and ~user paths to the full path.

Example:

import pathlib

path = pathlib.Path("~/Documents/test.txt")

print(path)
# => ~/Documents/test.txt

print(path.expanduser())
# => /Users/michael/Documents/test.txt