the logical operation confused me
Denis McMahon
denismfmcmahon at gmail.com
Thu Apr 10 19:28:40 EDT 2014
On Fri, 11 Apr 2014 07:02:33 +0800, 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" ?
I believe that:
[ (falsey condition) or ]* (first truthy condition) or (any condition)
[ or (any condition) ]*
will return (first truthy condition)
whereas:
(truthy condition) and [ (truthy condition) and ]* (last truthy condition)
will return (last truthy condition)
where "[ clause ]*" represents an optional clause that may be repeated
any number of times, "any condition" may evaluate falsey or truthy,
"first" and "last" relate to the position of the condition type in a left
to right evaluation sequence.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list