Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > Not exactly. In the case of no extension `os.path.splitext()` still works: > > In [14]: 'foo/bar.txt'.rsplit('.') > Out[14]: ['foo/bar', 'txt'] > > In [15]: 'foo/bar'.rsplit('.') > Out[15]: ['foo/bar'] > > In [16]: os.path.splitext('foo/bar') > Out[16]: ('foo/bar', '')
And crucially, it still works correctly if the file has no extension but a directory in the path has one: >>> 'foo.baz/bar'.rsplit('.') ['foo', 'baz/bar'] >>> os.path.splitext('foo.baz/bar') ('foo.baz/bar', '') Conclusion: forget about str.rsplit() (which I suggested), use os.path.splitext() instead :) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list