Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'completeness': 0.05; 'cpython': 0.05; 'interpreter': 0.05; 'python': 0.08; 'comparisons': 0.09; 'false,': 0.09; 'to:name:python- list@python.org': 0.15; '712': 0.16; 'caches': 0.16; '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:155.180.234.122': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:se3.svr.bankone.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:Poll': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'examples': 0.16; 'subject:question': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'values.': 0.23; 'received:169': 0.28; 'received:169.254': 0.28; 'true,': 0.29; "skip:' 10": 0.29; 'object.': 0.30; 'received:155': 0.30; 'received:159': 0.30; 'accuracy': 0.32; 'break': 0.32; 'objects': 0.32; 'certain': 0.34; 'to:addr:python-list': 0.35; 'phone:': 0.35; 'none': 0.35; 'something': 0.35; 'list:': 0.35; 'but': 0.37; 'charset:us-ascii': 0.37; 'some': 0.38; 'subject: (': 0.40; 'to:addr:python.org': 0.40; 'subject': 0.61; 'offers': 0.62; 'skip:1 10': 0.63; 'information,': 0.69; 'legal': 0.72; 'url:email': 0.72; 'bank': 0.75; 'sale': 0.75; 'investment': 0.77; 'purchase': 0.78; 'different.': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sj3.jpmchase.com q2EMFlt4007614 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1331763347; bh=r05nwL6j7Ak4b7ZiLizc8yLEEIuMaZGtu41dkgvTGyA=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=DlPNWr4IDq5OahpCvcUj6bVEG3FKvMb9sP/gB9HladZ/1ePLWS3udM8yJVaKTfnUv +mvV+FMh6ySXCD/w5c/jkTTZjTJYltuNWvilB6xhTqufm+c3zO9rA6zZAzQ0NSSvHc RF/OzVZOIjSAwoUpeYz0cQiVnfMdXw0UxC9NSUb0= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: Style question (Poll) Thread-Topic: Style question (Poll) Thread-Index: AQHNAiJLU/bfhqJ1hEOLTzSCd54dTJZqho8AgAAHj4D//8qysA== Date: Wed, 14 Mar 2012 22:15:38 +0000 References: 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.38] 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331763352 news.xs4all.nl 6950 [2001:888:2000:d::a6]:39489 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21629 > >> Which is preferred:=0D=0A> >>=0D=0A> >> for value in list:=0D=0A> >> = if not value is another_value:=0D=0A> >> value=2Edo_something()=0D=0A>= >> break=0D=0A> =0D=0A> Do you really mean 'is' or '=3D=3D'?=0D=0A=0D= =0ALet me expound on how 'is' and '=3D=3D' are very different=2E It may wor= k =0D=0Afor some comparisons but often not for others=2E Certain examples w= ork=0D=0Abecause of the Python implementation=2E =0D=0A=0D=0A>>> c =3D 1=0D= =0A>>> d =3D 1=0D=0A>>> c is d # This only works because CPython caches sma= ll values=2E=0D=0ATrue=0D=0A>>> c =3D=3D d=0D=0ATrue=0D=0A>>> a =3D 1000000= 0000000=0D=0A>>> b =3D 10000000000000=0D=0A>>> a is b=0D=0AFalse=0D=0A>>> a= =3D=3D b=0D=0ATrue=0D=0A>>> 10000000000000 is 10000000000000 =0D=0ATrue=0D= =0A=0D=0A'10000000000000 is 10000000000000' works because the interpreter c= aches=0D=0Athe number because it is on the same line=2E=0D=0A=0D=0A=0D=0AOn= ly use 'is' if you are looking for objects like True,=0D=0AFalse, None or s= omething that MUST be exactly the same object=2E=0D=0A=0D=0AIn general, use= '=3D=3D'=2E=0D=0A=0D=0A=0D=0A=0D=0ARamit=0D=0A=0D=0A=0D=0ARamit Prasad | J= PMorgan Chase Investment Bank | Currencies Technology=0D=0A712 Main Street = | Houston, TX 77002=0D=0Awork phone: 713 - 216 - 5423=0D=0A=0D=0A--=0D=0A= =0D=0AThis email is confidential and subject to important disclaimers and= =0D=0Aconditions including on offers for the purchase or sale of=0D=0Asecur= ities, accuracy and completeness of information, viruses,=0D=0Aconfidential= ity, legal privilege, and legal entity disclaimers,=0D=0Aavailable at http:= //www=2Ejpmorgan=2Ecom/pages/disclosures/email=2E