[Numpy-discussion] (a and b) != (b and a) ?
tim.hochberg at ieee.org
Wed Jun 12 13:38:24 CDT 2002
From: "Chris Barker" <Chris.Barker at noaa.gov>
> I imagine there is a compelling reason that "and" and "or" have not been
> overridden like the comparison operators, but it sure would be nice!
Because it's not possible?
"and" and "or" operate on the basis of the truth of their arguments, so the
only way you can affect them is to overide __nonzero__. Since this is a
unary operation, there is no way to get the equivalent of logical_and out of
In practice I haven't found this to be much of a problem. Nearly every time
I need to and two arrays together, "&" works just as well as logical_and. I
can certainly imagin ecases where this isn't true, I just haven't run into
them in practice.
More information about the Numpy-discussion