Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70071
| Date | 2014-04-10 16:13 -0700 |
|---|---|
| From | Gary Herron <gary.herron@islandtraining.com> |
| Subject | Re: the logical operation confused me |
| References | <CAOmh463=QOBR4DbLDowSeqhKi_vnGtoJDwg8Lk3iiwmhqhffiQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9155.1397172101.18130.python-list@python.org> (permalink) |
[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
Re: the logical operation confused me Gary Herron <gary.herron@islandtraining.com> - 2014-04-10 16:13 -0700
csiph-web