bizarre behavior using .lstrip

Pete Jereb petejereb at yahoo.com
Fri Sep 19 20:07:47 EDT 2003


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?

Note that if I just strip 'chg' and not the one whitespace character
next to it I get the expected result:

>>> print s.lstrip('chg')
 conn

but extending the right quote by one space not only strips the
whitespace but the c:

>>> print s.lstrip('chg ')
onn


Not really sure what's causing this, but it's making me change the
text parser  I'm 600 lines into.




More information about the Python-list mailing list