Pythonのstr.stripで拡張子を除くと意図しない挙動

こんなかんじ

>>> 'detail.xml'.strip('.xml')
'detai'

対策はこんな感じや

>>> 'detail.xml'[:-len('.xml')]
'detail'

こんな感じです。

>>> import os
>>> os.path.splitext('detail.xml')[0]
'detail'

で、これはバグなの?いや、仕様です。
Built-in Types — Python 3.7.3 documentation

the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:

そもそものstr.stripの挙動は、こんな感じです。

>>> ' spacious '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'

よくよく考えるとあたりまえですね(^^;

環境Python 2.7

参考
http://docs.python.org/library/stdtypes.html#str.strip
http://bytes.com/topic/python/answers/845353-strip-module-bug