[EMAIL PROTECTED] wrote:
> I've not used .any or .all, but having just taught my CS1 students about
> boolean operators, I was reminded that Python works as the following example
> describes:
>
> x = a and b
> # if both a and b are true, x is assigned b, otherwise x is assigned a
You are misleading your students.
If a is true, x is assigned b, otherwise x is assigned a:
For example:
x = [1] and ()
> x = a or b
> # if a is true, x is assigned a, if a is true, x is assigned a, if a is false
> and b is true, x is assigned b, if both a and b are false, x is assigned False
If a is true, x is assigned a, otherwise it is assigned b.
x = () or [1]
Check these out with:
print (() and [], () and [1], (1,) and [], (1,) and [1])
and
print (() or [], () or [1], (1,) or [], (1,) or [1])
Of course these doesn't address Arthur's issues, because Numeric and
friends deal with boolean conversion in an array-processing form.
--Scott David Daniels
[EMAIL PROTECTED]
_______________________________________________
Edu-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/edu-sig