Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.107 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.83; '*S*': 0.05; '>>>>': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'bug?': 0.16; 'lambda': 0.16; 'cc:addr:python- list': 0.17; 'mon,': 0.17; 'cheers,': 0.19; 'header:In-Reply- To:1': 0.21; 'seems': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; '(see': 0.23; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'binding': 0.30; 'chris': 0.34; 'received:google.com': 0.37; 'received:209.85': 0.37; 'subject:: ': 0.38; 'received:209': 0.39; '1st': 0.66; '30,': 0.84; '11:48': 0.84; 'sender:addr:chris': 0.84; 'received:209.85.218.46': 0.91; 'received:mail-yi0-f46.google.com': 0.91; 'to:addr:charter.net': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=KkOgJGz47wj6241y0+trB40LdP64Uqj2h54+JTono2k=; b=J007afV5Ghyzz+bXux7W0gYZM8i2T03Y2UE35bCzhZv/G5haAkV8BGgojIbjbIWXYf FCp6Da/cjpxKVqN02k0ZqodLX1rM4I/I2OU7IRDR2nUpt/ouBtpVjbXSEgUy07q0JiHB dEqmW2B5BzvJcCuwXUcRkCtac8ehuUqatNp+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=LzYh8LL3gtFf0vjlaLiq7UFzY1KyfiGEZgrVrMEyx+YLAIh64Zo2BuTEIjdpdM1Fb3 wZgeR1QFgZwaJnGLRSQacV27XXKbsStzi5gNxQ/KKBTk+28NyY8CiIKN0xBvaQH7VqXM ksaJWrzpbcM8EHCGXB2YgLAQaPAy/anHE5K7U= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Tue, 31 May 2011 00:00:04 -0700 X-Google-Sender-Auth: ihABQku2vzkDWmy6qdyE-JCUm7o Subject: Re: Something is rotten in Denmark... From: Chris Rebert To: harrismh777 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306825207 news.xs4all.nl 49045 [::ffff:82.94.164.166]:46683 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6713 On Mon, May 30, 2011 at 11:48 PM, harrismh777 wro= te: >>>> fs=3D[] >>>> fs =3D [(lambda n: i + n) for i in range(10)] >>>> [fs[i](1) for i in range(10)] > > [10, 10, 10, 10, 10, 10, 10, 10, 10, 10] =C2=A0 =C2=A0 =C2=A0 =C2=A0 <=3D= =3D=3D not good > > =C2=A0 =C2=A0( that was a big surprise! . . . ) > =C2=A0 =C2=A0 lambda? =C2=A0closure? =C2=A0scope? =C2=A0 bug? > > =C2=A0 =C2=A0 What is going on with the binding in the first construct...= this seems > to reduce the usefulness of lambda to a considerable extent? http://stackoverflow.com/questions/233673/lexical-closures-in-python (See 1st and 2nd answers) Cheers, Chris