[issue1748960] os.path.expandvars: expand string without modifying the environment

R. David Murray report at bugs.python.org
Mon Apr 6 14:45:28 CEST 2009


R. David Murray <rdmurray at bitdance.com> added the comment:

Python has had a way to do this since python 2.4:

>>> from string import Template
>>> fullPath =
Template("$ROOT/${SUBDIR/some/path").substitute(dict(ROOT='/users/geof',
SUBDIR='subdir'))
>>> fullPath
'/users/geof/subdir/some/path'

----------
components: +Library (Lib) -Extension Modules
nosy: +r.david.murray
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1748960>
_______________________________________


More information about the Python-bugs-list mailing list