Steve Dower added the comment:
My experience says the main reason people want to know whether the path is
absolute is to figure out whether to do `Path.cwd() / path` or not. According
to that MSDN page, they shouldn't because the path starts with "//" (that is,
the last character and the existence of the share name are irrelevant here).
Both pathlib and ntpath are reasonably consistent in determining the "drive" of
the path:
>>> splitdrive('\\\\server\\')[0]
'\\\\server\\'
>>> splitdrive('\\\\server')[0]
''
>>> Path('\\\\server\\').parts[0]
'\\\\server\\\\'
>>> Path('\\\\server').parts[0]
'\\'
I assume the bug in the last statement is what Antoine is referring to.
The difference in results then comes from how they determine roots.
>>> splitdrive('\\\\server\\')[1]
''
>>> splitdrive('\\\\server')[1]
'\\\\server'
>>> Path('//server/').root
'\\'
>>> Path('//server').root
'\\'
Pathlib always has a root, but splitdrive doesn't.
I'm not sure exactly which one to fix where, but hopefully that helps someone
else figure it out.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com