I love Python because it includes batteries, and I use the built-in functions to do the dirty work for me.
I always enjoyed using the os.path module to work with the file path, but recently I got unexpected results in Python 2.5 under Ubuntu linux, dealing with a line that represents the paths to Windows files:
filepath = r"c:\ttemp\FILEPA~1.EXE"
print os.path.basename(filepath)
'c:\\ttemp\\FILEPA~1.EXE']
print os.path.splitdrive(filepath)
('', 'c:\ttemp\\FILEPA~1.EXE')
WTF?
It ends the same way with the file path = u "c: \ ttemp \ FILEPA ~ 1.EXE" and filepath = "c: \ ttemp \ FILEPA ~ 1.EXE".
Do you have a key? Ubuntu uses UTF8, but I donβt feel that it has anything to do with it. My Python installation may have been confused, but I did not make any special settings that I remember.