Relative versus absolute paths on Windows

Christian Heimes lists at
Tue Nov 24 02:23:19 CET 2009

Gregory Ewing wrote:
>>>>> ntpath.join('d:\\foo', '\\bar')
>> '\\bar'
> This does seem like a bug, though -- the correct result
> should really be 'd:\\bar', since that's what you would
> get if you used the name '\\bar' with 'd:' as your current
> drive.

No, it's not a bug. Since \bar is an absolute path, all path segments
before the absolute path are ignored. This is documented at

>>> ntpath.isabs("\\bar")
>>> ntpath.join("ignored", "\\bar")

Posixpath follows the same rules, too.

>>> posixpath.join("..", "egg", "/var")
>>> posixpath.join("..", "egg", "var")


More information about the Python-list mailing list