Getting an unexpected result with os.path on Windows XP, Python 2.6.6:
a = "D:\temp\temp.txt"
os.path.dirname(a)
>>> 'D:' # Would expect 'D:\temp'
os.path.normpath(a)
>>> 'D:\temp\test.txt'
os.path.basename(a)
>>> '\temp\test.txt' #Would expect 'test.txt'
a.replace("\\", "/")
>>>'D:\temp\test.txt' # Would expect 'D:/temp/test.txt'
Can someone explain what is going on? How can I get the correct / expected behaviour? Why can't I replace the backslashes with front slashes?
EDIT: I am getting this path from a text field in a wxPython app, so it comes as a string with unescaped backslashes, and I can't seem to replace them with "replace".