[Python-ideas] os.path.join

Bruce Leban bruce at leapyear.org
Wed Oct 30 20:08:59 CET 2013


On Oct 30, 2013 11:25 AM, "MRAB" <python at mrabarnett.plus.com> wrote:
>
> On 30/10/2013 17:06, Bruce Leban wrote:
>>
>>  >>> drive, path = os.path.splitdrive(r'c:\abc')
>>  >>> drive + os.path.join(path, r'/def/g')
>> 'c:/def/g'

After I sent this I realized its more complicated than this. The above code
will fail joining (r'C:\a\b', r'D:\x\y').

>>  >>> os.path.join(r'c:\abc', r'\x\y', keep_drive_unc=True)
>> 'c:\\x\\y'
>>  >>> os.path.join(r'\\abc\def\ghi', r'\x\y', keep_drive_unc=True)
>> '\\\\abc\\def\\x\\y'
>>
> Shouldn't that be '\\\\abc\\x\\y'?

No. A UNC mount point is a server and a share name. \\server on its own
isn't enough. E.g., \\server\C$ is the equivalent of C:

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131030/2138edbd/attachment.html>


More information about the Python-ideas mailing list