[Tutor] lstrip removes '/' unexpectedly

Tim Johnson tim at johnsons-web.com
Fri Nov 30 21:26:05 CET 2007

There appears to still be a problem.
The email below was also sent, but I do not see
that it has been received. Send time was about
2 hours previous to this. 
(09:27:42 Alaska Standard Time)
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.
(and thanks also to Danny and Kent for clearing up the email problem)

More information about the Tutor mailing list