Key ideas in depth: assignments of condition results
In general, most people, at worse, assign the results of conditions thus:
a = variable < 10
if (a == True): # NB: is the same as "if(a):"
This is fortunately rarely needed, and it is better to keep conditions inside if statements where they won't be misunderstood. However, you can do more complicated assignments:
a = a or b
a = a and b
This resolves in the following complicated fashion:
a true, b true | a true, b false | a false, b true | a false, b false | |
---|---|---|---|---|
or | b | a | b | both zero |
and | b | b | a | both zero |