Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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; 'python,': 0.02; 'value,': 0.04; 'correct.': 0.07; 'expressions': 0.07; "subject:' ": 0.07; 'clean.': 0.09; 'false,': 0.09; 'generators': 0.09; 'objects,': 0.09; '(there': 0.16; '10:49': 0.16; 'boolean': 0.16; 'called,': 0.16; 'empty,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'iterators': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'ought': 0.16; 'timestamp': 0.16; 'wrote:': 0.18; 'otherwise,': 0.22; 'header :User-Agent:1': 0.23; "aren't": 0.24; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'am,': 0.29; "d'aprano": 0.31; 'restricted': 0.31; 'steven': 0.31; 'values.': 0.31; 'implemented': 0.33; 'subject:with': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'representing': 0.36; 'thank': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'you.': 0.62; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KrN0hwmN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=FBuLjTwyfbYA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=oXw8JkBlnBUA:10 a=8xYq7WTPh5cIX18_0v4A:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Fri, 14 Jun 2013 18:49:11 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Eval of expr with 'or' and 'and' within References: <51bb4986$0$29997$c3e8da3$5496439d@news.astraweb.com> <51BB52C5.60202@gmail.com> In-Reply-To: <51BB52C5.60202@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371232149 news.xs4all.nl 15950 [2001:888:2000:d::a6]:53299 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48196 On 14/06/2013 18:28, Michael Torrie wrote: > On 06/14/2013 10:49 AM, Steven D'Aprano wrote: >> Correct. In Python, all boolean expressions are duck-typed: they aren't >> restricted to True and False, but to any "true-ish" and "false-ish" >> value, or as the Javascript people call them, truthy and falsey values. >> >> There are a couple of anomalies -- the timestamp representing midnight is >> falsey, because it is implemented as a zero number of seconds; also >> exhausted iterators and generators ought to be considered falsey, since >> they are empty, but because they don't know they are empty until called, >> they are actually treated as truthy. But otherwise, the model is very >> clean. > > Good explanation! Definitely enlightened me. Thank you. > The general rule is that an object is true-ish unless it's false-ish (there are fewer false-ish objects than true-ish objects, e.g. zero vs non-zero int).