On this page
posixpath.expanduser
Prev: posixpath.exists | Up: posixpath | Next: posixpath.expandvars
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.expanduser
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import expanduser
Signature & Overview
posixpath.expanduser(path)
Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.
Usage
import posixpath
assert len(posixpath.expanduser('~')) > 0
Gotchas
- Expands
~usingHOME/USERPROFILE: Leaves unknown~userunchanged.
REPL Inspect
from posixpath import expanduser
help(expanduser)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/exists Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expandvars Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/abspath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getatime shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getctime shared tags: #posixpath, #stdlib