Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; 'none,': 0.05; "'',": 0.07; '[],': 0.07; 'e.g.,': 0.07; 'received:209.85.160.174': 0.07; 'python': 0.09; '"if': 0.09; 'none.': 0.09; 'spelling': 0.09; 'subject:while': 0.09; '{},': 0.09; 'cases': 0.15; 'value.': 0.15; '0.0,': 0.16; 'false:': 0.16; 'none"': 0.16; 'sense,': 0.16; 'set()': 0.16; 'true:': 0.16; 'wrote:': 0.17; '(in': 0.18; 'windows': 0.19; 'nearly': 0.23; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'have,': 0.27; "d'aprano": 0.29; 'steven': 0.29; 'expect': 0.31; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'useful': 0.36; 'should': 0.36; 'why': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'between': 0.63; 'skip:6 10': 0.63; 'more': 0.63; 'as:': 0.75; 'gotten': 0.75; 'truth': 0.75; 'habit': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=cr2A6s8jDZk1ast3cTuTo6s8WTT2Tz1Ht762y0lMVlA=; b=YyLoqbrjAZBl+xIPrjOd1t9BzYY2oKf2061l6DH/5mRRUHssshoKn6UErsBV+JhN35 Aadgsq+WaemWLlZq07c1t34PDqr68UQg/Fug3lJALip/o731zTo8kl6NHiogQAqmQsJd jBT9iCDTutGQYGGoSNx8Z6atlJNmho/zQPBYBuXHFAZ+YFM+OrmOOUQPZcebxReGIp+n W119U+OqN2UWL4FB2T+CdkEF8WtcLF/sZm3mJDLCVAY9HAxzXfUzxxyNgv7hdMaj09Tc 4zX0wK/ar5uxgaj607k9+1v8v3jsEisUC0QDZ6DFqWj6Eo62IY8LzxwNFYelL+Tj7ca2 +gtw== Date: Sun, 15 Jul 2012 12:02:37 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: Implicit conversion to boolean in if and while statements References: <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> X-Enigmail-Version: 1.4.3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342371768 news.xs4all.nl 6958 [2001:888:2000:d::a6]:57771 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25359 On 7/15/2012 5:56 AM, Steven D'Aprano wrote: > 3) Rather than distinguishing "true" from "false", a more useful > dichotomy is between "something" and "nothing". Python includes a number > of ways of spelling "nothing" of various types, such as: > > None, 0, 0.0, '', [], {}, set() > > and nearly everything else is "something". Okay, I see the value in this, but I don't understand why None has a truth value. I would expect None to mean "doesn't exist" or "unknown" or something like that - e.g., a value of 0 means 0 jelly beans in the jar and None means there isn't a jar. FWIW, I have, for a reason I forget, gotten into the habit of writing "if x is not None" when testing for None. However, I have not been writing "if x is True: ..."/"elif x is False: ..."/"else: 'ruh-roh'" when testing for True (in cases where a value of True or False makes sense, but any other value would not). Should I? -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803