Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79534
| Path | csiph.com!usenet.pasdenom.info!news.franciliens.net!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'context': 0.07; 'expressions': 0.07; 'none,': 0.07; 'alain': 0.09; 'false,': 0.09; 'false.': 0.09; 'interpreted': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thus,': 0.09; 'python': 0.11; '2.7': 0.14; '"in': 0.16; 'boolean': 0.16; 'containers': 0.16; 'evaluating': 0.16; 'exactly,': 0.16; 'false:': 0.16; 'frozensets).': 0.16; 'interest,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'selects': 0.16; 'statements,': 0.16; 'true:': 0.16; 'tuples,': 0.16; 'types,': 0.16; 'unequal,': 0.16; 'wrote:': 0.18; 'rules': 0.22; 'header:User-Agent:1': 0.23; 'apply.': 0.24; '(see': 0.26; 'academic': 0.26; 'compare': 0.26; 'somewhere': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'operations,': 0.30; 'sets': 0.30; 'statement': 0.30; 'received:132': 0.31; 'suites': 0.31; 'writes:': 0.31; '(including': 0.33; 'url:python': 0.33; '"the': 0.34; 'definition': 0.35; 'operations': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'false': 0.36; 'i.e.': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'flow': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'expression': 0.60; 'first': 0.61; 'evaluate': 0.72; 'kennedy': 0.84; 'manual,': 0.84; 'url:reference': 0.84; 'hand,': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
| Subject | Re: Truthiness |
| Date | Thu, 23 Oct 2014 17:01:43 +0200 |
| References | <61f0b04c-b827-4c03-b55d-4d5bd85b56f6@googlegroups.com> <87bnp23ksg.fsf@dpt-info.u-strasbg.fr> |
| 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 | <87bnp23ksg.fsf@dpt-info.u-strasbg.fr> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15113.1414076484.18130.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1414076484 news.xs4all.nl 2878 [2001:888:2000:d::a6]:42638 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 2487875557 |
| X-Received-Bytes | 4800 |
| Xref | csiph.com comp.lang.python:79534 |
Show key headers only | View raw
On 10/23/2014 04:47 PM, Alain Ketterlin wrote:
> Simon Kennedy <sffjunkie@gmail.com> writes:
>
>> Just out of academic interest, is there somewhere in the Python docs where the following is explained?
>>
>>>>> 3 == True
>> False
>>>>> if 3:
>> print("It's Twue")
>>
>> It's Twue
>>
>> i.e. in the if statement 3 is True but not in the first
>
> https://docs.python.org/2/reference/compound_stmts.html#the-if-statement
>
> says: "The if statement [...] selects exactly one of the suites by
> evaluating the expressions one by one until one is found to be true (see
> section Boolean operations for the definition of true and false)"
>
Exactly, but in
if 3 == True:
the expression is 3==True , in which 3 and True compare unequal, thus,
the expression is false.
On the other hand, in
if 3:
the expression to evaluate is just the int object and the rules below apply.
> and then:
>
> https://docs.python.org/2/reference/expressions.html#booleans
>
> says: "In the context of Boolean operations, and also when expressions
> are used by control flow statements, the following values are
> interpreted as false: False, None, numeric zero of all types, and empty
> strings and containers (including strings, tuples, lists, dictionaries,
> sets and frozensets). All other values are interpreted as true."
>
> (links are to the 2.7 version of the reference manual, I think not much
> has changed in 3.* versions.)
>
> -- Alain.
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Truthiness Simon Kennedy <sffjunkie@gmail.com> - 2014-10-23 07:30 -0700
Re: Truthiness Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-23 08:45 -0600
Re: Truthiness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-24 11:42 +1100
Re: Truthiness Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-10-23 16:47 +0200
Re: Truthiness Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-23 17:01 +0200
Re: Truthiness Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-23 16:07 +0000
Re: Truthiness Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-23 16:49 +0200
Re: Truthiness Skip Montanaro <skip.montanaro@gmail.com> - 2014-10-23 09:51 -0500
Re: Truthiness Simon Kennedy <sffjunkie@gmail.com> - 2014-10-23 07:56 -0700
Re: Truthiness random832@fastmail.us - 2014-10-23 11:24 -0400
csiph-web