For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
expanduser
def expanduser[PathLike: PathLike, //](path: PathLike) -> String
Expands a tilde "~" prefix in path to the user's home directory.
For example, ~/folder becomes /home/current_user/folder. On macOS and
Linux a path starting with ~user/ will expand to the specified user's home
directory, so ~user/folder becomes /home/user/folder.
If the home directory cannot be determined, or the path is not prefixed
with "~", the original path is returned unchanged.
Parameters:
- PathLike (
PathLike): The type conforming to the os.PathLike trait.
Args:
- path (
PathLike): The path that is being expanded.
Returns:
String: The expanded path.
Raises:
If the operation fails.