[Tutor] lstrip removes '/' unexpectedly

Tim Johnson tim at johnsons-web.com
Wed Dec 5 18:01:06 CET 2007


On Monday 03 December 2007, Tiger12506 wrote:
> >> ##########################
> >>
> >>>>> s = '/home/test/'
> >>>>> s1 = s.lstrip('/ehmo')
> >>>>> s1
> >>
> >> 'test/'
> >> ##########################
I've been having some problems posting to this list,
so this is also a kind of test:
I just wrote a global lstring
def lstrip(S,chars):
	if S.startswith(chars):
		return S[len(chars):]
	else: return S

It begs for a extension of the string object I guess,
but this (and a corollary rstrip) works for me.
Tim


More information about the Tutor mailing list