Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'languages,': 0.04; 'expressions': 0.07; 'interpreter.': 0.07; 'plenty': 0.07; 'feature.': 0.09; 'bool': 0.16; 'boolean': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nick': 0.16; 'types,': 0.16; "variable's": 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'case.': 0.24; 'instance,': 0.24; '15,': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'this.': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'therefore': 0.72; 'experiment': 0.84; 'subject:gets': 0.84; 'demand': 0.91; '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=xn6dNVonEMiI4TClkdI/yhDXzRjerrbnorxpFQ/1yoc=; b=z+m61dX3JWb9giatcUgEwZiXzJVBJr0leueoZh+HpFa1axM0on/osZaqr9Aos2x58K qzdDZ0wgHUB4qomVQ6RQAHcrvU3JoiFe6CR/oHEurapqnvZ1fLYTd12vRd0UrS/5Itrz RIB5BMEmR8xhzBNxQUVAjT7M3OYQRdLLWgVbNx4pN3IQcg1OIEs8WIfGYQQGVBvjQMHr ZvIMjUcVjGaZOEeIXfrDqwyd1d/7XQsw9bTF3SgeCnqLSl+fEqJR/g0w4zyB+wwEIfTF wWWLjo67pU9uAgFcpLUqV44YEZTxngBI2y/2y8Zw4SOm19uXESlBCyeXPreEHCLxtkKe 1tvQ== MIME-Version: 1.0 X-Received: by 10.52.155.67 with SMTP id vu3mr1074702vdb.94.1371230282327; Fri, 14 Jun 2013 10:18:02 -0700 (PDT) In-Reply-To: References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> <51b926a3$0$29997$c3e8da3$5496439d@news.astraweb.com> <51ba6e92$0$29997$c3e8da3$5496439d@news.astraweb.com> <51bb454c$0$29997$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 15 Jun 2013 03:18:02 +1000 Subject: Re: A certainl part of an if() structure never gets executed. 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371230285 news.xs4all.nl 15979 [2001:888:2000:d::a6]:52979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48191 On Sat, Jun 15, 2013 at 2:56 AM, Nick the Gr33k wrote: > What i'm trying to say that both these exprs are Boolean Expressions > therefore should return Boolean values not variable's values, even if they > are truthy. Okay, now we get to the nub of the matter. In some languages, what you say is the case. In C, for instance, 3 || 4 == 1 (C doesn't have dedicated True and False types, it uses 1 and 0). But there are very few situations where you actually need it to specifically be the boolean values, and plenty where you can make use of this additional feature. If you want to demand a bool from Python, there is a way to do this. Experiment with bool() in the interactive interpreter. ChrisA