"joram gemma" <[EMAIL PROTECTED]> wrote: > Hello, > > on windows python 2.4.1 I have the following problem > > >>> s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona' > >>> print s > D:\music\D\Daniel Lanois\For the beauty of Wynona > >>> t = 'D:\\music\\D\\' > >>> print t > D:\music\D\ > >>> s.lstrip(t) > 'aniel Lanois\\For the beauty of Wynona' > >>> > > why does lstrip strip the D of Daniel Lanois also?
Because the argument to lstrip is a *set of characters* to delete, not a string to delete. The string you passed it contained a 'D', so the 'D' got stripped. Imagine lstrip was defined something like: def lstrip (self, chars): temp = self while temp[0] in chars: temp = temp[1:] return temp and you should get the idea. I don't think the documentation for lstrip really makes this clear. I'm going to open a bug on the doc, and see what happens :-) I suspect what you really want to be doing is using the os.path module. It's got functions for tearing pathnames apart into components, and hides all the uglyness like whether / or \ is the directory separator on your particular system. -- http://mail.python.org/mailman/listinfo/python-list