o1da added the comment:
Ok, thank you. I thought it trims whole sequence or nothing.
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
Patrick Maupin added the comment:
Example
text = 'test1/1.jp2'
text.rstrip('.2jp')
'test1/1'
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
Patrick Maupin added the comment:
I think you misunderstand rstrip -- it works from the right, and checks to see
if the right-most character is in the string you have given it. As long as it
is, then it will remove the character and loop
--
nosy: +Patrick Maupin
New submission from o1da:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type help, copyright, credits or license for more information.
text = 'test1/1.jp2'
text.rstrip('.jp2')
'test1/1'
text = 'test1.jp2'
text.rstrip('.jp2')
'test1'
text = 'test1/2.jp2'
Martin Panter added the comment:
The 3.5 documentation of str.strip() was recently modified in Issue 24204 due
to this kind of misunderstanding. Perhaps other versions should be modified as
well, or the str.l/rstrip() methods, or the bytes() and bytearray() methods.
See also Issue 23560