ID EN
Pathlib

expanduser

Python 3.11

Return a new path with expanded ~ and ~user constructs, as returned by os.path.expanduser(). If a home directory can’t be resolved, RuntimeError is raised.

Syntax

PYTHON
Path.expanduser()

Examples

Example 1
PYTHON
>>> p = PosixPath('~/films/Monty Python')
>>> p.expanduser()
PosixPath('/home/eric/films/Monty Python')

See Also

os.path.expanduser() RuntimeError