Significance of "start" parameter to string method "endswith"

Boris Dušek boris.dusek at gmail.com
Thu Apr 19 15:58:14 EDT 2007


Hello,

what is the use-case of parameter "start" in string's "endswith"
method? Consider the following minimal example:

a = "testing"
suffix="ing"
a.endswith(suffix, 2)

Significance of "end" is obvious. But not so for "start".

Let's assume the "end" parameter is not used - then the function
should simple check that the last "len(suffix)" characters of "a" are
equal to "ing", no matter where we start (the function does not *scan*
the string from the "start", does it?)
Only case where it would make difference is if we had start +
len(suffix) < len(a)     (excuse possible "of-by-one" error :-)
Then the function would never return True. But is there a real use
case when we would test for endswith like this? (knowing that it must
return false?)

Thanks for any ideas/experience.
Boris




More information about the Python-list mailing list