Author gjb1002
Recipients
Date 2007-07-06.10:06:20
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I've several times wanted to expand a string in the way that os.path.expandvars does, but without modifying the actual environment.

If for example I have 

inputString = "$ROOT/${SUBDIR}/some/path"

and I want to find expanded versions of this, I have to do something like

os.environ["ROOT"] = "/users/geoff"
os.environ["SUBDIR"] = "subdir"
fullPath = os.path.expandvars(inputString)

The problem is that my program is multithreaded and I don't want to globally change os.environ. All I want is the information "fullPath". I'd like to be able to create a local "env" dictionary and pass it to os.path.expandvars as an optional second argument.

I attach a patch for posixpath.py and ntpath.py, though this is untested and is intended to show what I mean in practice.
History
Date User Action Args
2007-08-23 15:58:56adminlinkissue1748960 messages
2007-08-23 15:58:56admincreate