Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed4a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'else:': 0.03; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'boolean': 0.16; 'interest,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'true:': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'academic': 0.26; 'somewhere': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'statement': 0.30; '>>>>': 0.31; 'context.': 0.31; 'received:132': 0.31; 'url:python': 0.33; 'but': 0.35; 'there': 0.35; 'false': 0.36; 'i.e.': 0.36; 'opposed': 0.36; 'url:org': 0.36; 'example,': 0.37; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'first': 0.61; 'here': 0.66; 'kennedy': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Wolfgang Maier Subject: Re: Truthiness Date: Thu, 23 Oct 2014 16:49:05 +0200 References: <61f0b04c-b827-4c03-b55d-4d5bd85b56f6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: px1.ruf.uni-freiburg.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <61f0b04c-b827-4c03-b55d-4d5bd85b56f6@googlegroups.com> 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414075725 news.xs4all.nl 2916 [2001:888:2000:d::a6]:54619 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79530 On 10/23/2014 04:30 PM, Simon Kennedy wrote: > Just out of academic interest, is there somewhere in the Python docs where the following is explained? > https://docs.python.org/3/library/stdtypes.html#truth-value-testing >>>> 3 == True > False as opposed to: https://docs.python.org/3/library/stdtypes.html#comparisons >>>> if 3: > print("It's Twue") > > It's Twue > > i.e. in the if statement 3 is True but not in the first > Here is the misunderstanding: it is not true that 3 is True in the if example, but it's evaluated as True in a boolean context. Illustration: >>> 3 == True False >>> bool(3) == True True >>> bool(3) is True True If you combine if and a comparison, it behaves like in your first example: >>> if 3 == True: print('True') else: print('False') False