Bug in string.lstrip?
Will McGugan
news at NOwillmcguganSPAM.com
Mon Aug 23 12:19:23 EDT 2004
Brian wrote:
> Hello - has anyone else had trouble with string.lstrip stripping too
> much? Here's what I get (Python 2.3.4):
>
> >>> import string
> >>> string.lstrip("test/one/two/a.b.c", "test/one/")
> 'wo/a.b.c'
> >>> string.lstrip("test/one/two/a.b.c", "test/one")
> 'wo/a.b.c'
> >>> string.lstrip("test/one/two/a.b.c", "test/one/tw")
> 'a.b.c'
> >>>
>
> Similar things happened with the strip() string method. Am I missing
> something, or should I file a bug report?
>
> Thanks,
>
>
> Brian
I think lstrip() just removes the characters that are contained in the
second string. The order of characters in the second string is irrelevant.
For example..
>>> "abcdefg".lstrip("bac" )
'defg'
Your examples are correct because it removes a run of any of the
characters contained in the seconds string.
Perhaps someone can explain this better than I can. ;)
Will McGugan
More information about the Python-list
mailing list