bizarre behavior using .lstrip

Peter Hansen peter at engcorp.com
Fri Sep 19 20:11:48 EDT 2003


Pete Jereb wrote:
> 
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
> win32
> 
> >>> s = 'chg bonn_fee'
> >>> print s
> chg bonn_fee
> >>> print s.lstrip('chg ')
> bonn_fee
> 
> >>> s = 'chg conn_fee'
> >>> print s
> chg conn_fee
> >>> print s.lstrip('chg ')
> onn_fee
> 
> Does this make any sense at all?  where did the lead c in conn_fee go?

Based on the behaviour you describe, I would assume lstrip() 
removes, starting at the beginning of the string, all characters
which are *anywhere* in the argument string you give it, until
it encounters a character not in that string, at which point it
stops.

-Peter




More information about the Python-list mailing list