[Tutor] Would somebody kindly...

Clayton Kirkwood crk at godblessthe.us
Wed Oct 29 02:02:21 CET 2014


Ah, Alan sent an answer also, but this one answers the last tidbit. Alan had the some_list and pair the same name, presumably creating a temporary tuple and when the loop is done, the temporary replaces the original.

Thanks

Clayton 

!-----Original Message-----
!From: Danny Yoo [mailto:dyoo at hashcollision.org]
!Sent: Tuesday, October 28, 2014 4:23 PM
!To: Clayton Kirkwood
!Cc: Python Tutor Mailing List
!Subject: Re: [Tutor] Would somebody kindly...
!
!On Tue, Oct 28, 2014 at 4:13 PM, Clayton Kirkwood <crk at godblessthe.us>
!wrote:
!> Explain this double speak(>:
!>
!> [pair for pair in values if key == pair[0]]
!
!Hi Clayton,
!
!Here is a rewording of that expression to an approximately equivalent
!statement:
!
!#######################
!some_list = []
!for pair in values:
!    if key == pair[0]:
!        some_list.append(pair)
!#######################





More information about the Tutor mailing list