Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"if': 0.04; 'arguments': 0.05; 'completeness': 0.05; 'instance': 0.05; 'herein': 0.07; 'python': 0.07; 'notation.': 0.09; 'programmer': 0.11; '712': 0.16; 'affiliates,': 0.16; 'boolean': 0.16; 'currencies': 0.16; 'naive': 0.16; 'opened,': 0.16; 'readable': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:169.70.190': 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; 'solicitation': 0.16; 'strike': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'argument': 0.16; 'weight': 0.18; 'developer,': 0.19; 'source.': 0.19; '(or': 0.22; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; '(and': 0.22; 'values': 0.23; "haven't": 0.23; 'applicable,': 0.23; 'reflect': 0.24; 'received:169': 0.25; 'received:169.254': 0.25; 'lists,': 0.26; 'instead': 0.26; 'problem': 0.29; 'explicitly': 0.29; 'forgot': 0.29; "python's": 0.29; 'probably': 0.30; 'chase': 0.31; 'none,': 0.31; 'received:155': 0.31; 'received:159': 0.31; 'received:169.254.1': 0.31; 'strings,': 0.31; 'turns': 0.31; 'format.': 0.31; 'anyone': 0.31; 'to:addr:python-list': 0.32; 'thank': 0.32; "i've": 0.33; '(including': 0.33; 'legally': 0.33; 'fairly': 0.33; 'phone:': 0.33; 'change': 0.34; 'accepted': 0.35; 'header:Received:8': 0.35; 'purposes': 0.35; 'returned': 0.35; 'arising': 0.35; 'disclosure': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'some': 0.37; 'refer': 0.37; 'accuracy': 0.38; 'but': 0.38; 'affect': 0.39; 'under': 0.39; 'comments': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'empty': 0.40; 'would': 0.40; 'necessarily': 0.40; 'street': 0.40; 'contained': 0.40; 'might': 0.40; 'co.,': 0.60; 'transaction.': 0.60; 'virus': 0.61; 'subject': 0.61; 'you.': 0.61; 'free': 0.62; 'market': 0.63; 'legal': 0.64; 'law.': 0.65; 'contact': 0.65; 'relating': 0.68; 'hand,': 0.72; 'offer': 0.72; 'sale': 0.74; 'investment': 0.77; 'bank': 0.78; 'purchase': 0.80; 'affiliates.': 0.84; 'defect': 0.84; 'prices,': 0.84; 'instrument': 0.95; 'notice.': 0.95 X-DKIM: Sendmail DKIM Filter v2.5.6 sz2.jpmchase.com p4BHduO7001413 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=jpmchase.com; s=smtpout; t=1305135596; bh=eNGDxEYZVafknGafHOaxcrO1yuIE7Q3yxla9tV1 q+XE=; h=From:To:Date:Subject:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=g8rjWj1RlKA B+7ZJ4VlQK3QmD56CdzbWrtX3AlzvB+MgM2ki4JMo4d9qhcW+f8Uja8gMFrgAqulppe ZWlTUK1SJhXtts0qSvuh48ch4UgBKB2fnZKKL1hHzzNuD11kPrpgqlhO3p8C1a5ZCpI QZg/ps/yC9kVZqtJJ5un4e1Ai8= From: "Prasad, Ramit" To: "'python-list@python.org'" Date: Wed, 11 May 2011 13:39:44 -0400 Subject: RE: checking if a list is empty Thread-Topic: checking if a list is empty Thread-Index: AcwP1X8F63JVrqnqTC6gdPpmyZ0HaQAK0iRg References: <200e93c2-6b87-4113-9c6f-85815e51ea77@28g2000yqu.googlegroups.com> <4dc4b3c5$0$29991$c3e8da3$5496439d@news.astraweb.com> <4dca7db5$0$29980$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4dca7db5$0$29980$c3e8da3$5496439d@news.astraweb.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 39 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305135608 news.xs4all.nl 81484 [::ffff:82.94.164.166]:49144 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5135 > I don't mean to insult anyone, but I've heard and read all the arguments = against Python's truth-testing, and they=0D=0A>don't impress me in the slig= htest=2E Most of them strike me as silly=2E The only argument that carries = any weight to me is=0D=0A>one which I haven't seen anyone raise:=0D=0A=0D= =0A>"if x:" turns something which arguably could have been a mistake ("oops= , I forgot to write the condition!") into valid=0D=0A>code=2E=0D=0A=0D=0ATh= e only problem I have had with the "if x:" notation is when I have values t= hat might be empty lists, empty strings, None, or a boolean value being ret= urned from the same source=2E But this is probably an instance when a good = programmer would explicitly check the type instead of the naive "if x:" not= ation=2E=0D=0A=0D=0AOn the other hand, as a fairly n00b Python (and n00b Pe= rl) developer, I find the notation "if not x:" to be far more English reada= ble than "if x=3D=3DNone or len(x)=3D=3D 0 or x=3D=3D0 or bool(x):" (or som= e derivative/combination of those)=2E =0D=0A=0D=0A=0D=0A=0D=0ARamit=0D=0A= =0D=0ARamit Prasad | JPMorgan Chase Investment Bank | Currencies Technology= =0D=0A712 Main Street | Houston, TX 77002=0D=0Awork phone: 713 - 216 - 5423= =0D=0AThis communication is for informational purposes only=2E It is not=0D= =0Aintended as an offer or solicitation for the purchase or sale of=0D=0Aan= y financial instrument or as an official confirmation of any=0D=0Atransacti= on=2E All market prices, data and other information are not=0D=0Awarranted = as to completeness or accuracy and are subject to change=0D=0Awithout notic= e=2E Any comments or statements made herein do not=0D=0Anecessarily reflect= those of JPMorgan Chase & Co=2E, its subsidiaries=0D=0Aand affiliates=2E= =0D=0A=0D=0AThis transmission may contain information that is privileged,= =0D=0Aconfidential, legally privileged, and/or exempt from disclosure=0D=0A= under applicable law=2E If you are not the intended recipient, you=0D=0Aare= hereby notified that any disclosure, copying, distribution, or=0D=0Ause of= the information contained herein (including any reliance=0D=0Athereon) is = STRICTLY PROHIBITED=2E Although this transmission and any=0D=0Aattachments = are believed to be free of any virus or other defect=0D=0Athat might affect= any computer system into which it is received and=0D=0Aopened, it is the r= esponsibility of the recipient to ensure that it=0D=0Ais virus free and no = responsibility is accepted by JPMorgan Chase &=0D=0ACo=2E, its subsidiaries= and affiliates, as applicable, for any loss=0D=0Aor damage arising in any = way from its use=2E If you received this=0D=0Atransmission in error, please= immediately contact the sender and=0D=0Adestroy the material in its entire= ty, whether in electronic or hard=0D=0Acopy format=2E Thank you=2E=0D=0A=0D= =0APlease refer to http://www=2Ejpmorgan=2Ecom/pages/disclosures for=0D=0Ad= isclosures relating to European legal entities=2E