some path issues on windows

Brad brad at 16systems.com
Sat Mar 29 03:31:07 CET 2008


When reading a file into a list that contains windows file paths like this:

c:\documents and settings\brad\desktop\added_software\asus\a.txt

I get a list that contains paths that look like this:

c:\\documents and settings\\brad\\desktop\\added_software\\asus\\a.txt

So, my list contains those funky file paths. And, when I do this:

for root, dirs, files in os.walk('C:\\'):
     for f in files:
         print os.path.join(root,f)

I get the more normal path again:

c:\documents and settings\brad\desktop\added_software\asus\a.txt

This makes path comparison difficult as I have different strings (the 
extra \'s). I've tried os.path.normpath(line_reading_in_from_file) but I 
still get the funky \\ paths. How can I read the paths with an r'path' 
like meaning?

Thanks,
Brad



More information about the Python-list mailing list