Bug in string.lstrip?

B

Brian

Hello - has anyone else had trouble with string.lstrip stripping too
much? Here's what I get (Python 2.3.4):

Similar things happened with the strip() string method. Am I missing
something, or should I file a bug report?

Thanks,


Brian
 
M

Michael Hudson

Brian said:
Hello - has anyone else had trouble with string.lstrip stripping too
much? Here's what I get (Python 2.3.4):


Similar things happened with the strip() string method. Am I missing
something, or should I file a bug report?

Strip considers the second parameter as a *set* of characters to
remove.

Cheers,
mwh
 
W

Will McGugan

Brian said:
Hello - has anyone else had trouble with string.lstrip stripping too
much? Here's what I get (Python 2.3.4):


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..
'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
 
B

Brian Gough

Brian said:
Hello - has anyone else had trouble with string.lstrip stripping too
much? Here's what I get (Python 2.3.4):

'wo/a.b.c'

The second argument of lstrip has a different meaning from what you
think it does --- see the library documentation for the string module
for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top