Python str.strip weird behavior
x.strip(y) will delete all characters that appear in y , starting at the beginning and end of x .
It means
'foo42'.strip('1234567890') == 'foo' becuase '4' and '2' displayed in '1234567890' .
Use os.path.splitext if you want to remove the file extension.
>>> import os.path >>> t1 = "abcd.org.gz" >>> os.path.splitext(t1) ('abcd.org', '.gz') The argument given to strip is the set of characters to be deleted, not the substring. From the docs :
The chars argument is a string specifying the set of characters to remove.