[Python-ideas] proposed sequence method: index_subseq()
Chris Angelico
rosuav at gmail.com
Tue Aug 27 17:01:56 CEST 2013
On Wed, Aug 28, 2013 at 12:57 AM, Jess Austin <jess.austin at gmail.com> wrote:
> (0, 1, 2, 3, 4, 5, 6, 7, 8).index_subseq((3,4,5))) # slice(3, 6, None)
> [0, 1, 2, 3, 4, 5, 6, 7, 8].index_subseq((3,4,5)))
> (0, 1, 2, 3, 4).index_subseq((3,4,5))) # ValueError
> [0, 1, 2, 3, 4].index_subseq((3,4,5)))
Apologies for bikeshedding, but it looks to me like this would do
better as a stand-alone function than a method. I was going to suggest
itertools, but since its first argument has to be repeatably
indexable, that may not be the best place for it; in any case, though,
making it a module-level function somewhere allows it to not care
about the type of its first arg.
ChrisA
More information about the Python-ideas
mailing list