[Tutor] lstrip removes '/' unexpectedly

Tiago Saboga tiagosaboga at terra.com.br
Fri Nov 30 18:36:39 CET 2007


Read this:

----
In [50]: print str.lstrip.__doc__
S.lstrip([chars]) -> string or unicode

Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
---

The point is "characters in chars", not strings.

---
In [52]: 'abababbbaacaaba'.lstrip('ab')
Out[52]: 'caaba'
---

Cheers,

Tiago.


More information about the Tutor mailing list