strings getting unnecessarily cut in lstrip

Maxim Mercury maxim.mercury at gmail.com
Sun Nov 21 22:12:43 EST 2010


I was using the lstrip to trim the left occurance of a string, and it
didnt seem to work for some cases. but when i investigated there does
seem to be an issue with some combination of strings
here is one case
 p1 = "abcd"
 p2 = 'def'                    # $abc
 sym = '_'
 str1 = p1 + sym + p2
 str1 = str1.lstrip(p1+sym)
 print str1                             # this prints ef instead of
def

can someone explain why this is happening ?



More information about the Python-list mailing list