Terry J. Reedy added the comment:
Without any test code (other than my examples) to illustrate the desired new
functionality, I may have misunderstood. But I read the George's prose (but
not the SO link) and everything I wrote is relevant to what I thought it said.
The request appears to be
Steven D'Aprano added the comment:
Terry, I'm not sure if you've read this enhancement request correctly or not,
because your reply when closing covers over a lot of detail which is not
relevant to this feature request.
> Extending this idea to 'subsequence in sequence' or
>
Terry J. Reedy added the comment:
Lists, tuples, ranges, dicts, and other builtin collection objects already work
with 'in'.
>>> 1 in [1,2,3]
True
>>> 4 in range(9)
True
For historical reasons, stings have both 'find' and 'index'. The only
difference is returning -1 (a C-ism) versus raising
Steven D'Aprano added the comment:
Only 3.7 can receive new functionality.
Here is a pure Python implementation of a subsequence test:
https://code.activestate.com/recipes/577850-search-sequences-for-sub-sequence/
It appears to be reasonably popular on Activestate: it has about 7000 views,
New submission from George Shuklin:
I found that Python provides 'find()' and 'in' methods for strings, but lacking
same functionality for lists.
Because strings and lists are very similar, it's reasonable to expect same
function available for both.
Here long and rather ugly hack list on