Nick Coghlan added the comment:
os.relpath *does* give you a relative path between two directories.
The problem you are encountering is that, on Windows, a relative path
doesn't even *exist* if the two directories are on different drives
(which is exactly what the error message says).
Jason R. Coombs added the comment:
The documentation changes I suggested make no mention to Windows pathing
quirks. They instead clarify two aspects:
1) cross-platform behavior (how the path is interpreted) and
2) platform-specific implementation of relpath (what Python exceptions
to expect in
Nick Coghlan added the comment:
The path *returned* is relative to the start point. The target path is
figured out normally (i.e. relative to the current directory if an
absolute path is not given).
In your example, you aren't passing in an absolute Windows path - you
give a path relative to th
Jason R. Coombs added the comment:
Based on the response, then the documentation is inadequate. I don't
want to make a stink about this, but I think the issue is still
unresolved. If it would be better to discuss this elsewhere, please advise.
The documentation says "Return a relative filepath
Nick Coghlan added the comment:
It's not the current directory that's the problem, it's the current
drive. Windows has no absolute root directory - instead, it has a root
directory for each drive. That means that "\\dir" is a path relative to
the current drive rather than an absolute path. You n
New submission from Jason R. Coombs :
A simple test fails:
Python 2.6.3 (r263rc1:75186, Oct 2, 2009, 20:40:30) [MSC v.1500 32 bit
(Intel)] on win32
>>> import os
>>> os.path.relpath('\\bar', 'd:\\')
Traceback (most recent call last):
File "", line 1, in
File "C:\python\lib\ntpath.py", line