pretty strange behavior of "strip"

Tim Roberts timr at
Tue Dec 9 05:28:03 CET 2008

Guy Doune <cesium5500 at> wrote:

>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]
> >>> test[4].strip('.html')
> >>> test[2].strip('.html')

Because it removes any periods, h's, t's, m's, or l's at the beginning or
ending of the string.  That "t" is in the middle.  In this case, the
stripping stopped at the "q" and the "s".
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list