What is the pythonic way to test if there is a tuple starting with another tuple in collection? actually, I am really after the index of match, but I can probably figure out from test example
for example:
c = ((0,1),(2,3))
# (0,) should match first element, (3,)should match no element
I should add my python is 2.4 and/or 2.5
thanks
Edit:
Thanks to the OP for the addition explanation of the problem.
S.Mark’s nested list comprehensions are pretty wicked; check ’em out.
I might opt to use an auxiliary function:
Original answer:
Does using a list-comprehension work for you?:
List comps were introduced in 2.0.