Message52809
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.
|
|
| Date |
User |
Action |
Args |
| 2007-08-23 15:58:56 | admin | link | issue1748960 messages |
| 2007-08-23 15:58:56 | admin | create | |
|