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: 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; '>>>': 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 This is a multi-part message in MIME format. --------------040603080206000706060208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------040603080206000706060208 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
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
--------------040603080206000706060208--