>> ##########################
>>>>> s = '/home/test/'
>>>>> s1 = s.lstrip('/ehmo')
>>>>> s1
>> 'test/'
>> ##########################
>>
>> Take a closer look at the documentation of lstrip, and you should see
>> that
>> what it takes in isn't treated as a prefix: rather, it'll be treated as a
>> set of characters.
>>
>
> But then the real bug is why does it not strip the trailing '/' in
> 'test/' or the 'e' that is in your set?

Because lstrip strips the characters within that set, starting from the
left,
until it encounters a character not in that set. Then it stops. This code
produces the same results, though surely more slowly.

def lstrip(s, set):
  for x in s:
    if x in set:
      return lstrip(s[1:],set)
    return s

JS

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to