NT variables are passed around as %var% instead of varorvar or varor{var}. Providing support for this gives a seamless user experience for NT users using Python. E.g. os.path.expandvars('%TEMP%') now does what is expected on NT. I updated the docstring, could not find any tests or documentation references in svn for this portion of code.
Logged In: YES user_id=341410 I believe that there are two changes that are desireable; the functionality offered in this patch (expansion of %VAR% environment variables), and ~user\subpath expansion. Recursive re-application of variable expansion shouldn't occur. I can merge the two patches that adds the functionality to ntpath.expanduser and ntpath.expandvars .
Logged In: YES user_id=341410 I've added a new patch to http://python.org/sf/957650 that adds both the expanduser and expandvars case. The expandvars case is slightly different from what the OP submitted, if only in that it won't mask ValueErrors that don't come from the str.index() call.