Problem with string parsing
Russell Blau
russblau at hotmail.com
Tue Oct 5 10:48:48 EDT 2004
"Mike Howard" <mhoward at mahoward.com> wrote in message
news:948b993a.0410050638.3a0340ec at posting.google.com...
> If I do this:
> string.lstrip('1_mature_dt=10-May-2002','1_mature_dt=')
why not '1_mature_dt=10-May-2002'.lstrip('1_mature_dt=') ?
> I get:
> '0-May-2002'
> Which I did not expect
You have been bitten by the obscure documentation of the .lstrip() method.
The second argument is viewed as a collection of characters, not as a
substring; so, since there is a "1" in the collection of characters to be
stripped, the method removed the "1" at the beginning of the date. It stops
when it gets to the first character *not* in the collection, which in your
case is the "0".
--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.
More information about the Python-list
mailing list