!-----Original Message----- !From: Tutor [mailto:[email protected]] On !Behalf Of Dave Angel !Sent: Tuesday, October 28, 2014 6:34 PM !To: [email protected] !Subject: Re: [Tutor] Would somebody kindly... ! ! !> ! 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.
I am using 3.4.1. ! !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 - [email protected] !To unsubscribe or change subscription options: !https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
