Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'caller': 0.07; 'completeness': 0.07; 'subject:skip:c 10': 0.07; 'python': 0.09; '%r"': 0.09; 'arg': 0.09; 'received:155': 0.09; 'def': 0.10; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'sees': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'verbose': 0.16; '>>>': 0.18; 'to:name :python-list@python.org': 0.20; 'skip:- 40': 0.21; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'accuracy': 0.27; 'subject:list': 0.28; 'chase': 0.29; 'received:169': 0.29; 'function': 0.30; 'header:Received:8': 0.30; 'to:addr:python-list': 0.33; 'phone:': 0.34; 'false': 0.35; 'but': 0.36; 'charset:us-ascii': 0.36; 'being': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'investment': 0.67; 'purchase': 0.67; 'sale': 0.76; 'bank': 0.77; '712': 0.84; 'received:169.254.8': 0.84; 'houston,': 0.91; 'subject:funny': 0.91 X-DKIM: OpenDKIM Filter v2.1.3 sj1.jpmchase.com q6DGCmjv008977 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1342195972; bh=zT4bKDMaFI+Y9FCcta4UC4TpL3rnXi9Vvn9fD1qdfY0=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=LznWX3WEw0uiYkDS8HTa1sQ+6xqTnGvyFa+VYliKCnFZ2xJs7dfjsyyJyeCCrRWvY bp1o59Dna/OBc0TGSPLd6mO3aKmqLHgXuAOTyuAq3s/vsiUEYcanNIQXpThkAicIIx 9sbICA+bn19HEDF7gSyzVaSJACL8Ay0t1R7bGH58= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: lambda in list comprehension acting funny Thread-Topic: lambda in list comprehension acting funny Thread-Index: AQHNYP2xMI5tpoL+PkusODrgV6TbgZcnYhRQ Date: Fri, 13 Jul 2012 16:12:40 +0000 References: <03943ea6-5914-4de4-821c-055bed1d5804@f9g2000pbd.googlegroups.com> <4fffc1fd$0$29965$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342195975 news.xs4all.nl 6882 [2001:888:2000:d::a6]:52980 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25269 > VERBOSE =3D True=0D=0A> =0D=0A> def function(arg):=0D=0A> if VERBOSE:= =0D=0A> print("calling function with arg %r" % arg)=0D=0A> proce= ss(arg)=0D=0A> =0D=0A> def caller():=0D=0A> VERBOSE =3D False=0D=0A> = function(1)=0D=0A> =0D=0A> ---------------------------------------------= =0D=0A> Python semantics: function sees VERBOSE False=0D=0A> Haskell semant= ics: function sees VERBOSE True=0D=0A=0D=0A>>> def caller():=0D=0A=2E=2E=2E= VERBOSE =3D False=0D=0A=2E=2E=2E function(1)=0D=0A>>> def function= (arg):=0D=0A=2E=2E=2E if VERBOSE:=0D=0A=2E=2E=2E print("calling = function with arg %r" % arg)=0D=0A=2E=2E=2E =0D=0A>>> VERBOSE =3D True= =0D=0A>>> caller()=0D=0Acalling function with arg 1=0D=0A=0D=0AI might be b= eing OCD, but caller needs `global VERBOSE` for that to=0D=0Awork as you ex= plain=2E=0D=0A=0D=0ARamit=0D=0A=0D=0A=0D=0ARamit Prasad | JPMorgan Chase In= vestment Bank | Currencies Technology=0D=0A712 Main Street | Houston, TX 77= 002=0D=0Awork phone: 713 - 216 - 5423=0D=0A=0D=0A--=0D=0A=0D=0AThis email i= s confidential and subject to important disclaimers and=0D=0Aconditions inc= luding on offers for the purchase or sale of=0D=0Asecurities, accuracy and = completeness of information, viruses,=0D=0Aconfidentiality, legal privilege= , and legal entity disclaimers,=0D=0Aavailable at http://www=2Ejpmorgan=2Ec= om/pages/disclosures/email=2E