rstrip()

Thomas Jollans thomas at jollans.com
Fri Jul 16 13:14:19 EDT 2010


On 07/16/2010 06:58 PM, Jason Friedman wrote:
> $ python
> Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
> [GCC 4.4.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> "x.vsd-dir".rstrip("-dir")
> 'x.vs'
> 
> I expected 'x.vsd' as a return value.

>>> "x-vsd-dir".rstrip("-dir")
'x-vs'
>>> "x-vsd-dir".rstrip("123id-r456")
'x-vs'
>>> "x-vsd-dir".rstrip("-di")
'x-vsd-dir'
>>> "fooabc".rstrip("bca")
'foo'
>>>

http://docs.python.org/py3k/library/stdtypes.html#str.rstrip ::

""" The chars argument is not a suffix; rather, all combinations of its
values are stripped: """






More information about the Python-list mailing list