IIRC correctly the form 'd:efg' refers to a relative path on the d: drive, based on the current working directory _of that drive_. Since it requires a default base path to be relative on, that form wouldn't work cross drives. However if we used the same drive, we might be willing to allow a relative path prefixed with a drive letter. os.path.join(r'c:\abc\foo', 'd:efg') # ERROR os.path.join(r'd:\abc\foo', 'd:efg') # returns r'd:\abc\efg' On Sat, Nov 2, 2013 at 9:15 PM, <random832@fastmail.us> wrote:
On Wed, Oct 30, 2013, at 13:06, Bruce Leban wrote:
os.path.join(r'c:\abc', r'\def\g') # Windows paths '\\def\\g'
On Windows \def\g is a drive-relative path not an absolute path. To get the right result you need to do:
drive, path = os.path.splitdrive(r'c:\abc') drive + os.path.join(path, r'/def/g') 'c:/def/g'
What should it do in the opposite case: where the path is a relative path on another drive? I.e. os.path.join('c:\\abc','d:efg'). This is archaic, sure, but if we're going to say it's always equivalent to "as if the first argument were the cwd", this needs to be handled too. Fortunately, I don't think there's any way to specify this with a UNC share. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas