string.lstrip stripping too much?
Fredrik Lundh
fredrik at pythonware.com
Sun May 15 17:35:22 EDT 2005
"joram gemma" wrote:
> on windows python 2.4.1 I have the following problem
>
> >>> s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona'
> >>> print s
> D:\music\D\Daniel Lanois\For the beauty of Wynona
> >>> t = 'D:\\music\\D\\'
> >>> print t
> D:\music\D\
> >>> s.lstrip(t)
> 'aniel Lanois\\For the beauty of Wynona'
> >>>
>
> why does lstrip strip the D of Daniel Lanois also?
because you told it to do that?
>>> help(str.lstrip)
Help on method_descriptor:
lstrip(...)
S.lstrip([chars]) -> string or unicode
Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
(chars is a set of characters, not a prefix. the string "D:\\music\\D\\"
contains a D, obviously. to strip off a prefix, use s[len(prefix):])
</F>
More information about the Python-list
mailing list