pretty strange behavior of "strip"
Mark Tolonen
metolone+gmane at gmail.com
Fri Dec 5 09:50:36 EST 2008
"Guy Doune" <cesium5500 at yahoo.ca> wrote in message
news:493936EC.9030606 at yahoo.ca...
> Ok, didn't show the whole problem...
>
> I will read the doc anyway, but why "questions.html" keep it "t"??
>
> >>> test=['03.html', '06.html', 'questions.html', '04.html', 'toc.html',
> '01.html', '05.html', '07.html', '02.html', '08.html']
> >>> test[4]
> 'toc.html'
> >>> test[4].strip('.html')
> 'oc'
> >>> test[2].strip('.html')
> 'questions'
It doesn't strip the character set from the whole string, it strips it from
the beginning and end of the string only. If it encounters a character that
isn't in the set, it stops. Does this make it more clear?
>>> 'aabdabcdccb'.strip('cba')
'dabcd'
-Mark
More information about the Python-list
mailing list