Relative versus absolute paths on Windows

Nobody nobody at
Tue Nov 24 07:02:15 CET 2009

On Tue, 24 Nov 2009 02:23:19 +0100, Christian Heimes wrote:

> 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.

Except that a path without a drive letter *isn't* an absolute path in
any meaningful sense. The fact that os.path.isabs() disagrees is a defect
in os.path.isabs() (I won't call it a bug, as it's documented as behaving
that way).

The upshot is that the standard library is missing important functionality
on Windows, i.e. testing whether a path is absolute, and resolving a
relative path relative to an absolute path.

More information about the Python-list mailing list