os.path.dirname adds unremoveable spaces?

Jason asldfkjasldfj at asldfkjasldkfjasdf.com
Sat Apr 17 12:53:03 EDT 2004


Here's the code I'm using:

####################################
import os, string
for root, dirs, files in os.walk('/home/_Comedy'):
        for file in files:
                str = os.path.dirname(file)
                print root, str.strip(), "/", file.strip()

####################################
The problem is that even after using strip(), it still prints a list like 
this:


/home/_Comedy/ISIRTA  / ISIRTA - 1966.03.28 - s02e03 - Ali Baba.mp3
/home/_Comedy/ISIRTA  / ISIRTA - 1966.04.04 - s02e04 - Nelson.mp3
/home/_Comedy/ISIRTA  / ISIRTA - 1966.04.18 - s02e06 - Angus Prune.mp3  
	    	         ^^^^^
    	    	    	    ^^^^^
I can't remove these mystery spaces that I'm pointing to no matter what I 
try.  Neither the directories or filenames have spaces before or after 
them.  Even if they did, they should've been removed when I used the strip 
command.

Any ideas?



More information about the Python-list mailing list