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


Groups > comp.lang.python > #70071 > unrolled thread

Re: the logical operation confused me

Started byGary Herron <gary.herron@islandtraining.com>
First post2014-04-10 16:13 -0700
Last post2014-04-10 16:13 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#70071 — Re: the logical operation confused me

FromGary Herron <gary.herron@islandtraining.com>
Date2014-04-10 16:13 -0700
SubjectRe: the logical operation confused me
Message-ID<mailman.9155.1397172101.18130.python-list@python.org>

[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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web