[Tutor] lstrip removes '/' unexpectedly
Tim Johnson
tim at johnsons-web.com
Mon Dec 3 19:29:17 CET 2007
Trying this again. This list has not be receiving all
of my emails......
==================================
On Friday 30 November 2007, Eric Brunson wrote:
> Tim Johnson wrote:
> > Hello:
> > I'm seeing some strange behavior with lstrip operating
> > on string representations of *nix-style file paths
> >
> > Example:
> >>>> s = '/home/test/'
> >>>> s1 = s.lstrip('/home')
> >>>> s1
> >
> > 'test/' ## '/test/' was expected! '/' was unexpectedly removed
>
Hi Folks:
I actually resent this as a test because I've had problems contacting
this list. The understanding of it percolated up to my wee little brain
shortly after the first send (which didn't arrive).
I wrote the following as a solution:
def lstrip(S,chars):
if S.startswith(chars):
return S[len(chars):]
else: return S
and a global rstrip would be an easy corrolary.
Thanks
More information about the Tutor
mailing list