[Python-ideas] os.path.join

random832 at fastmail.us random832 at fastmail.us
Sun Nov 3 03:15:20 CET 2013


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.


More information about the Python-ideas mailing list