> Explain this double speak(>: > [pair for pair in values if key == pair[0]] > I understand the ‘for pair in values’. I assume the first > ‘pair’ creates the namespace
The namespace question depends on the version of Python. Python 2.x does not do any scoping. But in version 3.x, the variable pair will go away. So please tell us the version you're asking about. The list comprehension always creates a list, not a tuple. Pair is a tuple if and only if the corresponding element of values is a tuple. In fact there's no requirement that those elements of values have the same type. Of course if they're not of length 2, then pair is a lousy name. And if one of them is not subscriptable, then the if expression will blow up. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor