Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.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.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'subject:Python': 0.06; 'javascript,': 0.07; 'arguments': 0.09; 'php,': 0.09; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'it;': 0.16; 'ought': 0.16; 'wrote:': 0.18; "python's": 0.19; 'thu,': 0.19; '(the': 0.22; 'lets': 0.24; "i've": 0.25; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'languages': 0.32; 'sense': 0.34; "can't": 0.35; 'something': 0.35; 'etc.)': 0.35; 'objects': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'returning': 0.36; 'useful': 0.36; 'list': 0.37; 'list.': 0.37; 'easily': 0.37; 'represent': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'extremely': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'term': 0.63; 'between': 0.67; 'as:': 0.81; "'and'": 0.84; 'distinguish': 0.84; 'pike': 0.84; 'unifying': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=v/2nKZPO4siWpNXX+RA4YyoLx5D+Y6jftWEkuy0ZwH0=; b=g3Uc9gh+rZdxv0e1z9dhVvCaP/+W94iVfrfTMuHKkCSdUiL2/PAlVz1660e92jDlw+ mgFfT7w8JMEbmyZmpfup+SYdFUJEaOpbCj+6NwHNGbahqygH2qETQIvNuI3IelWcJYXr sqKUgYC9zvcnWxfrOl2oPFr+V8oDT5ck1QfvNSYgpfCsDOjCH+RwPZkEjWr2h0Kirx1I Y4bbTVTmgjKv68RMn/wtW8s1A26igMcr7w9Po6wJN/drWiCqqDW+dN2I2Ye6VlyHE7Ur NTRpwgNEI+tWC7nyMQ6CS0EQ9U8sy8EvCt0kML4SI8i7G5ANtkproQ9NiZ3fS2Kfe9ni b8nQ== MIME-Version: 1.0 X-Received: by 10.68.234.73 with SMTP id uc9mr10770385pbc.142.1381367634478; Wed, 09 Oct 2013 18:13:54 -0700 (PDT) In-Reply-To: <5255f684$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <91180c35-413f-4b65-a224-917d8d68b7ec@googlegroups.com> <5255f684$0$29984$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 10 Oct 2013 12:13:54 +1100 Subject: Re: Python's and and Pythons or From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381367643 news.xs4all.nl 15960 [2001:888:2000:d::a6]:39561 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56530 On Thu, Oct 10, 2013 at 11:36 AM, Steven D'Aprano wrote: > Other languages (Ruby, PHP, Javascript, etc.) also have > truthy and falsey values, but in my opinion none of them have got it > right. Python has a unifying model of truthiness: objects which represent > "something" ought to be truthy, those which represent "nothing" ought to > be falsey Python's model makes a lot of sense. The only other system that I've seen that makes as much sense is Pike's, which can be summarized as: Falsey: 0 (the integer; does the job of None in many contexts) Truthy: Everything else. Python lets you distinguish easily between an empty list and a list with something in it; Pike lets you distinguish between a list and the absence of a list. The use of 'and' and 'or' in returning their arguments is an extremely useful one, but I'm not sure it has a name. Pike and Lua have the same behaviour; neither offers a good term for it. Recommendation: Invent a term if you can't find one, and start using it. :) ChrisA