Using Python 2.6 on Windows I have a function that needs to accept a path name as an arg. I'm running into issues when certain specific paths are passed.
C:\users\bob\something.png #this is handled no prob.
C:\users\bob\nothing.png #this generates a WindowsError
C:\users\bob\test.png #this also generates a WindowsError
What I'm gathering is that the \n
in the "nothing" path is being interpreted as a new line, and the \t
in the "test" path is being interpreted as a tab.
If I print out the path names, that's what appears to be happening.
print os.path.abspath("C:\users\bob\nothing.png")
C:\users\bob
othing.png
Same for the 'test' path, except a tab instead of a new line.
The only thing I've come up with so far is to do a check to see if \n
or \t
are in the path name, and then handle it accordingly, but there must assuredly be a better way.
if '\n' in path_name:
#escape slash, move on
What would a better way be?