[docs] str.lstrip(char) takes too many characters

Eli Bendersky eliben at gmail.com
Sun Mar 11 04:28:14 CET 2012


> I have a string     trans_11.79_1.78_133392642.sdds
>
> if I execute
>
> >>  test = trans_11.79_1.78_133392642.sdds
> >> test.lstrip("trans" +  "_"  + 11.79 + "_" + 1.78 + "_").rstrip(".sdds")
>
> I get the result
> 33392642
>
>
> a friend verified this problem.


Byron, here's the documentation of lstrip:

----
str.lstrip([chars])

Return a copy of the string with leading characters removed. The chars
argument is a string specifying the set of characters to be removed.
If omitted or None, the chars argument defaults to removing
whitespace. The chars argument is not a prefix; rather, all
combinations of its values are stripped:
----

Read the last sentence, especially, and note that "1" appears as one
of the chars that should be removed.

Eli


More information about the docs mailing list