python - os.path.relpath not returning a relative path when using drive as start point -


why os.path.relpath, on windows, not returning proper relative path when using drive start point, either explicit or implied (current directory)

>>> os.getcwd() 'u:\\projects' >>> os.path.relpath(r'd:\foo\something', r"d:\\") '..\\foo\\something' >>> os.chdir("d:\\") >>> os.getcwd() 'd:\\' >>> os.path.relpath(r'd:\foo\something') '..\\foo\\something'     >>> os.path.relpath(r'd:\foo\something', r"d:\\foo") 'something' 

i expecting see

'foo\\something' 

or

'.\\foo\\something' 

does have os.path.join note on windows?

note on windows, since there current directory each drive, os.path.join("c:", "foo") represents path relative current directory on drive

i using python 2.7

issue fixed under python 2.7.1

issue #5117: fixed root directory related issue on posixpath.relpath() , ntpath.relpath().


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -