Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'circular': 0.03; '"if': 0.04; 'does.': 0.07; 'imply': 0.07; 'pep': 0.07; 'python': 0.07; 'argument,': 0.09; 'null,': 0.09; 'operator,': 0.09; 'sun,': 0.09; 'throw': 0.09; 'pm,': 0.11; 'wrote:': 0.14; '"not"': 0.16; "'not": 0.16; '*why*': 0.16; 'concise,': 0.16; 'discourse': 0.16; 'exception?': 0.16; 'surprising': 0.16; '\xa0:)': 0.16; '\xa0this': 0.16; 'suggest': 0.19; 'describes': 0.19; 'language': 0.20; 'seeing': 0.21; '(or': 0.22; 'subject:list': 0.22; 'header :In-Reply-To:1': 0.22; '"not': 0.23; 'null': 0.23; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; "i'm": 0.26; 'message- id:@mail.gmail.com': 0.28; 'testing': 0.28; 'beyond': 0.28; 'received:209.85.161': 0.29; 'problem': 0.29; '"this': 0.29; 'bound': 0.29; 'list': 0.30; 'clear,': 0.31; 'construct': 0.31; 'list"': 0.31; 'does': 0.31; 'to:addr:python-list': 0.32; '...': 0.32; '(including': 0.33; 'relatively': 0.33; 'skip:" 10': 0.34; 'actually': 0.34; 'clearly': 0.34; 'decide': 0.34; 'put': 0.35; 'explicit': 0.35; 'stands': 0.35; 'think': 0.36; 'else': 0.37; 'should': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'anything': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'empty': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'necessarily': 0.40; 'might': 0.40; '2011': 0.62; 'hand,': 0.72; "'not'": 0.84; 'something.': 0.91; 'that),': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=vzsB7e2VePsEYAcY7gK1aLY0Xj2NLgNd61I6BE1URWY=; b=suHghG99O68g+2mKluCLrO6FGZeS96EKnqIhBeaZbAWS0NarOVwPBVhMmvr151W1li wm73W1ly52ouOybBeGZROTk2TIiNCqWAI1NtVGSfDCoS7i4epiDEfnrl096w/AEXAIDu g06g+rm6VRRRvsIrq2uBd86VKCZ/uT2IKwXWg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=cU9LS35Y40qiuUPCtpv0I8nqgUn2V5iDBHBnpTtAA/FMr/C3U76PYmER5JVp3x3yX1 /8m/QYBkcAELK4kq+Z8BOBHzJ+7PqO1PAjaBW25jicKW/YOYOvvkNR8ziQizD7qaDA9i z8PekEQryura+uLnzb7VlLGh/SLhhKE//VIUc= MIME-Version: 1.0 In-Reply-To: References: <9hYwp.5805$xo2.3333@newsfe07.iad> <4dc502c7$0$29991$c3e8da3$5496439d@news.astraweb.com> <4dc6a39a$0$29991$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sun, 8 May 2011 22:34:04 -0600 Subject: Re: checking if a list is empty To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 48 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304915676 news.xs4all.nl 41103 [::ffff:82.94.164.166]:41100 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4977 On Sun, May 8, 2011 at 9:33 PM, harrismh777 wrote= : > =A0 Why should the negation of a list imply that the list empty? =A0... n= or any > other abstract condition which is not well suited to 'not' ? (forget pyth= on > for a moment... then move on to my argument...) > > =A0 What made the python development team (or individual) decide that the > logical construct =A0 'not list' =A0 would return True if the list is emp= ty? > To say that "This is the way we do it in Python because Python does it th= is > way"--- =A0goes beyond pedantic becoming circular and redundant. > > =A0 On the other hand, if you were to tell me *why* you think that the lo= gical > construct 'not list' should be logically True when the list is empty--- w= hen > clearly negating a list would not necessarily mean to make the list empty > (including destroying it)... then you might be seeing my point. "bool(list)" describes whether the list contains something. "Not" being a logical operator, it stands to reason that "not list" should mean the same thing as "not bool(list)". Anything else would be surprising and pointlessly convoluted. If "not list" bothers you, then I would suggest that your problem is actually with "bool(list)". > =A0 =A0 =A0 =A0... =A0should return True only if 'list' is bound to NULL,= or if the > name 'list' would throw a name exception... Why? Should "not False" return True only if "False" is bound to NULL (whatever you mean by that), or if the name "False" would throw a name exception? > =A0 =A0 =A0 =A0... =A0and, Python should have an explicit way of testing = for an empty > list that is clear, concise, and easy to understand even for the relative= ly > new Python programmer. =A0This is not intended to generate counter argume= nt, > its just my feedback on a language construct that I find to be inconsiste= nt > logically. ... Please, no pedantic discourse explaining why I'm wrong... > just put in into a PEP and move on. =A0:) It does. "if len(list) =3D=3D 0"