[Python-ideas] FInd first tuple argument for str.find and str.index
rrr at ronadam.com
Thu Sep 6 13:58:40 CEST 2007
Guido van Rossum wrote:
> I was surprised to find that startswith and endswith support this, but
> it does make sense. Adding a patch to 2.6 would cause it to be merged
> into 3.0 soon enough.
I'll give it a try but it may take me a while to do it. If someone else
wants to do this and is more familiar with the string and unicode objects
that would be good.
> On 9/4/07, Ron Adam <rrr at ronadam.com> wrote:
>> Could we add the ability of str.index and str.find to accept a tuple as the
>> first argument and return the index of the first item found in it.
>> This is similar to how str.startswith and str.endswith already works.
>> | startswith(...)
>> | S.startswith(prefix[, start[, end]]) -> bool
>> | Return True if S starts with the specified prefix, False otherwise.
>> | With optional start, test S beginning at that position.
>> | With optional end, stop comparing S at that position.
>> | prefix can also be a tuple of strings to try.
>> This would speed up cases of filtering and searching when more than one
>> item is being searched for. It would also simplify building iterators that
>> filter and yield multiple items in order.
>> A general google code search seems to show it's a generally useful thing to
>> (searching for python specific code doesn't show much because python
>> doesn't have a findfirst function of any type.)
>> Python-ideas mailing list
>> Python-ideas at python.org
More information about the Python-ideas