John Posner wrote:
Another "missing feature" candidate: sublist
>>> 'bc' in 'abcde'
True
>>> list('bc') in list('abcde')
False
I'm not aware of any idioms, but how about a simple function?
def listinlist(list1, list2):
"checks if list1 is in list2"
if not list1:
return True
if not list2:
return False
length = len(list1)
pos = 0
while True:
try:
pos = list2.index(list1[0], pos)
except ValueError:
return False
if list2[pos:pos+length] == list1:
return True
pos += 1
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list