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