Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.05; 'python': 0.07; 'conditional': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'scientists': 0.09; '~ethan~': 0.09; 'wrote:': 0.14; 'boolean': 0.16; 'gmt,': 0.16; 'lisp': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'remember.': 0.16; 'tend': 0.16; 'useful,': 0.16; 'exists': 0.19; 'language': 0.20; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; 'right,': 0.22; 'values': 0.23; 'objects': 0.24; 'equivalent': 0.26; 'tests': 0.26; 'there.': 0.26; 'object': 0.27; 'list': 0.30; 'fact': 0.31; 'language.': 0.31; 'programmers': 0.31; 'to:addr:python-list': 0.32; 'idea': 0.32; 'things': 0.33; 'using': 0.34; 'got': 0.34; 'header:User-Agent:1': 0.35; 'languages.': 0.35; 'list.': 0.35; 'think': 0.36; 'case,': 0.36; 'other,': 0.38; 'steven': 0.38; 'anything': 0.38; 'to:addr:python.org': 0.39; 'count': 0.40; 'empty': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'simple,': 0.60; '2011': 0.62; 'natural': 0.63; 'received:hostgator.com': 0.64; 'learnt': 0.68; 'received:websitewelcome.com': 0.71; 'evaluate': 0.72; '"nothing"': 0.84; 'received:69.93': 0.91 Date: Wed, 11 May 2011 08:53:24 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: checking if a list is empty References: <9hYwp.5805$xo2.3333@newsfe07.iad> <4dc4b351$0$29991$c3e8da3$5496439d@news.astraweb.com> <4dca90c1$0$29980$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-Source: X-Source-Args: X-Source-Dir: 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305128490 news.xs4all.nl 81483 [::ffff:82.94.164.166]:40845 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5126 Hans Georg Schaathun wrote: > On 11 May 2011 13:36:02 GMT, Steven D'Aprano > wrote: > : > In this case, the interpretation of an arbitrary object as a boolean is > : > peculiar for python. > : > : Incorrect. It is widespread among many languages. Programmers have been > : writing conditional tests using arbitrary values since 1958 when Lisp > : introduced the concept. > > The fact that you need to list language by language which objects > evaluate as false or equivalent to false illustrates that this has > to be learnt language by language. Allowing arbitrary objects is > one thing, the particular interpretation is peculiar. Like so many other things Python got right, I think it got this right as well. "something" vs "nothing" is simple, useful, and easy to remember. > By now we have gotten past that old-fashioned idea that 0 > is not a number. Computer scientists even tend to count 0 as a > natural number. When 0 is a number as real and existent as any other, > one would think that the empty list is also as real and existent as > any other list. Python is not concerned with whether it exists -- that's a name binding; Python is concerned with whether anything is there. 0 apples is nothing and a an empty list is nothing as well. ~Ethan~