On this page
posixpath.expandvars
Prev: posixpath.expanduser | Up: posixpath | Next: posixpath.getatime
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.expandvars
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import expandvars
Signature & Overview
posixpath.expandvars(path)
Expand shell variables of form $var and ${var}. Unknown variables are left unchanged.
Usage
import posixpath, os
os.environ['DEMO_P'] = 'ok'
try:
assert posixpath.expandvars('$DEMO_P') == 'ok'
finally:
os.environ.pop('DEMO_P', None)
Gotchas
- Leaves undefined variables unexpanded rather than raising
KeyError.
REPL Inspect
from posixpath import expandvars
help(expandvars)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/expanduser Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getatime 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/exists shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getctime shared tags: #posixpath, #stdlib