you have to use os.path.splitext
In [3]: os.path.splitext('test.test.txt')
Out[3]: ('test.test', '.txt')
In [4]: os.path.splitext('test.test.txt')[0]
Out[4]: 'test.test'
full reference for similar manipulations can be found here http://docs.python.org/2/library/os.path.html