Suppose you have a sequence of 2-tuples:
seq_of_tups = (('a', 1), ('b', 2), ('c', 3))
and you want to test if 'a' is the first item of any tuple in the sequence.
What is the most Pythonic way?
Convert to a dictionary and test for keys, which seems easy enough to understand? i.e.
'a' in dict(seq_of_tups)
Use a cute zip trick which is is not particularly clear unless you know the trick? i.e.
'a' in zip(*seq_of_tups)[0]
Or be really explicit with map? i.e.
'a' in map(lambda tup: tup[0], seq_of_tups)
Or is there a better way than any of these choices?
the above solution will exit as soon as
ais found, proof: