the logical operation confused me
Gary Herron
gary.herron at islandtraining.com
Thu Apr 10 19:13:49 EDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140410/e4091a76/attachment.html>
More information about the Python-list
mailing list