Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70071

Re: the logical operation confused me

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gary.herron@islandtraining.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.058
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'output': 0.05; 'string': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'wrote:': 0.18; 'meant': 0.20; '>>>': 0.22; 'header:User-Agent:1': 0.23; '&gt;&gt;&gt;': 0.24; 'received:emailsrvr.com': 0.24; 'string,': 0.24; 'received:(smtp server)': 0.26; 'header:In-Reply-To:1': 0.27; 'explained': 0.31; 'gary': 0.31; 'operators': 0.31; 'probably': 0.32; 'url:python': 0.33; 'subject:the': 0.34; 'false': 0.36; 'possible': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'length': 0.61; 'url:5': 0.61; 'here:': 0.62; 'power': 0.76; 'yourself': 0.78; '"not': 0.84; '*and*': 0.84; 'confusing': 0.84
X-Virus-Scanned OK
Date Thu, 10 Apr 2014 16:13:49 -0700
From Gary Herron <gary.herron@islandtraining.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: the logical operation confused me
References <CAOmh463=QOBR4DbLDowSeqhKi_vnGtoJDwg8Lk3iiwmhqhffiQ@mail.gmail.com>
In-Reply-To <CAOmh463=QOBR4DbLDowSeqhKi_vnGtoJDwg8Lk3iiwmhqhffiQ@mail.gmail.com>
Content-Type multipart/alternative; boundary="------------040603080206000706060208"
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.9155.1397172101.18130.python-list@python.org> (permalink)
Lines 94
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1397172101 news.xs4all.nl 2856 [2001:888:2000:d::a6]:49425
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70071

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 04/10/2014 04:02 PM, length power wrote:
> >>> "ok" or "not ok"
> 'ok'
> >>> "ok" and "not ok"
> 'not ok'
> >>>
>
> why "ok" or "not ok" output "ok"  , "ok" and "not ok"  output "not ok" ?
>
>
>

You are probably confusing yourself with the string "not ok".  That 
string, and any other non-empty string is considered true
 >>> bool("not ok")
True
 >>> bool("ok")
True

perhaps you meant
 >>> not "ok"
False



Once past that possible confusion, the return value of the *and* and 
*or* operators are explained here:
     https://docs.python.org/release/2.5.2/lib/boolean.html

Gary Herron

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: the logical operation confused me Gary Herron <gary.herron@islandtraining.com> - 2014-04-10 16:13 -0700

csiph-web