testing if a list contains a sublist

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Aug 19 22:10:29 EDT 2011


Johannes wrote:

> hi list,
> what is the best way to check if a given list (lets call it l1) is
> totally contained in a second list (l2)?
[...]

For anyone interested, here's a pair of functions that implement
sub-sequence testing similar to str.find and str.rfind:


http://code.activestate.com/recipes/577850-search-sequences-for-sub-sequence/



-- 
Steven




More information about the Python-list mailing list