[Tutor] lstrip removes '/' unexpectedly

jim stockford jim at well.com
Fri Nov 30 20:17:28 CET 2007


it might work just to strip 'home' and leave

print s1
//test/

the '/' character is a separator, so
/this//that/andmore/
is, at least at the shell level, the same as
/this/that/andmore/
i.e. any number of '/' characters adjacent has
the effect of a single '/' character (again, at the
shell level).

On Nov 30, 2007, at 9:17 AM, 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
> Any comments or corrective measures are welcome
> thanks
> Tim
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



More information about the Tutor mailing list