may be a bug in string.rstrip

michael poeltl michael.poeltl at univie.ac.at
Fri Nov 23 01:33:02 EST 2007


hi,

what about this


>>> 'exe.torrent'.split('.')[0]
'exe'
>>> 'exe.torrent'.rstrip('toren').rstrip('.')
'exe'
>>>

that's what you need, isn't it?

On Friday 23 November 2007 05:09:50 am kyo guan wrote:
> Hi :
>
> 	Please look at this code:
> >>> 'exe.torrent'.rstrip('.torrent')
>
> 'ex'			<-----  it should be 'exe', why?
>
> but this is a right answer:
> >>> '120.exe'.rstrip('.exe')
>
> '120'			<------ this is a right value.
>
> 	there is a bug in the rstrip, lstrip there isn't this problem.
>
>
>
> Kyo.


michael



More information about the Python-list mailing list